本文整理汇总了PHP中Codeception\Util\Locator::humanReadableString方法的典型用法代码示例。如果您正苦于以下问题:PHP Locator::humanReadableString方法的具体用法?PHP Locator::humanReadableString怎么用?PHP Locator::humanReadableString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codeception\Util\Locator
的用法示例。
在下文中一共展示了Locator::humanReadableString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHumanReadableString
public function testHumanReadableString()
{
$this->assertEquals("'string selector'", Locator::humanReadableString("string selector"));
$this->assertEquals("css '.something'", Locator::humanReadableString(['css' => '.something']));
$this->assertEquals("css selector '.something'", Locator::humanReadableString(WebDriverBy::cssSelector('.something')));
try {
Locator::humanReadableString(null);
$this->fail("Expected exception when calling humanReadableString() with invalid selector");
} catch (\InvalidArgumentException $e) {
}
}
示例2: fail
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null)
{
$selectorString = Locator::humanReadableString($selector);
if (!$this->string) {
throw new \PHPUnit_Framework_ExpectationFailedException("Element {$selectorString} was found", $comparisonFailure);
}
$output = "There was {$selectorString} element";
$output .= $this->uriMessage("on page");
$output .= str_replace($this->string, "<bold>{$this->string}</bold>", $this->nodesList($nodes, $this->string));
$output .= "\ncontaining '{$this->string}'";
throw new \PHPUnit_Framework_ExpectationFailedException($output, $comparisonFailure);
}
示例3: testGetArguments
public function testGetArguments()
{
$by = WebDriverBy::cssSelector('.something');
$step = $this->getStep([null, [$by]]);
$this->assertEquals('"' . Locator::humanReadableString($by) . '"', $step->getArguments(true));
$step = $this->getStep([null, [['just', 'array']]]);
$this->assertEquals('"just","array"', $step->getArguments(true));
$step = $this->getStep([null, [function () {
}]]);
$this->assertEquals('"lambda function"', $step->getArguments(true));
$step = $this->getStep([null, [[$this, 'testGetArguments']]]);
$this->assertEquals('"callable function"', $step->getArguments(true));
}
示例4: testGetArguments
public function testGetArguments()
{
$by = WebDriverBy::cssSelector('.something');
$step = $this->getStep([null, [$by]]);
$this->assertEquals('"' . Locator::humanReadableString($by) . '"', $step->getArgumentsAsString());
$step = $this->getStep([null, [['just', 'array']]]);
$this->assertEquals('["just","array"]', $step->getArgumentsAsString());
$step = $this->getStep([null, [function () {
}]]);
$this->assertEquals('"Closure"', $step->getArgumentsAsString());
$step = $this->getStep([null, [[$this, 'testGetArguments']]]);
$this->assertEquals('["StepTest","testGetArguments"]', $step->getArgumentsAsString());
$step = $this->getStep([null, [['PDO', 'getAvailableDrivers']]]);
$this->assertEquals('["PDO","getAvailableDrivers"]', $step->getArgumentsAsString());
}
示例5: fail
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null)
{
if (!count($nodes)) {
throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
}
$output = "Failed asserting that any element by " . Locator::humanReadableString($selector);
$output .= $this->uriMessage('on page');
if (count($nodes) < 5) {
$output .= "\nElements: ";
$output .= $this->nodesList($nodes);
} else {
$message = new Message("[total %s elements]");
$output .= $message->with(count($nodes))->style('debug');
}
$output .= "\ncontains text '" . $this->string . "'";
throw new \PHPUnit_Framework_ExpectationFailedException($output, $comparisonFailure);
}
示例6: parseArgumentAsString
protected function parseArgumentAsString($argument)
{
if (is_object($argument)) {
if (method_exists($argument, '__toString')) {
return (string) $argument;
}
if (get_class($argument) == 'Facebook\\WebDriver\\WebDriverBy') {
return Locator::humanReadableString($argument);
}
return $this->getClassName($argument);
}
if (is_array($argument)) {
foreach ($argument as $key => $value) {
if (is_object($value)) {
$argument[$key] = $this->getClassName($value);
}
}
return $argument;
}
if (is_resource($argument)) {
return (string) $argument;
}
return $argument;
}
示例7: testGetArguments
public function testGetArguments()
{
$by = WebDriverBy::cssSelector('.something');
$step = $this->getMockBuilder('\\Codeception\\Step')->setConstructorArgs([null, [$by]])->setMethods(null)->getMock();
$this->assertEquals('"' . Locator::humanReadableString($by) . '"', $step->getArguments(true));
}
示例8: parseArgumentAsString
protected function parseArgumentAsString($argument)
{
if (is_object($argument)) {
if (method_exists($argument, '__toString')) {
return (string) $argument;
}
if (get_class($argument) == 'Facebook\\WebDriver\\WebDriverBy') {
return Locator::humanReadableString($argument);
}
}
if ($argument instanceof \Closure) {
return 'lambda function';
}
if (is_callable($argument)) {
return 'callable function';
}
if (!is_object($argument)) {
return $argument;
}
return isset($argument->__mocked) ? $this->formatClassName($argument->__mocked) : $this->formatClassName(get_class($argument));
}
示例9: stringifyArgument
protected function stringifyArgument($argument)
{
if (is_string($argument)) {
return '"' . strtr($argument, ["\n" => '\\n', "\r" => '\\r', "\t" => ' ']) . '"';
} elseif (is_resource($argument)) {
$argument = (string) $argument;
} elseif (is_array($argument)) {
foreach ($argument as $key => $value) {
if (is_object($value)) {
$argument[$key] = $this->getClassName($value);
}
}
} elseif (is_object($argument)) {
if (method_exists($argument, '__toString')) {
$argument = (string) $argument;
} elseif (get_class($argument) == 'Facebook\\WebDriver\\WebDriverBy') {
$argument = Locator::humanReadableString($argument);
} else {
$argument = $this->getClassName($argument);
}
}
return json_encode($argument, JSON_UNESCAPED_UNICODE);
}
示例10: __construct
public function __construct($selector, $message = null)
{
$selector = Locator::humanReadableString($selector);
parent::__construct($message . " element with {$selector} was not found.");
}