本文整理汇总了PHP中SimpleExpectation::isExpectation方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleExpectation::isExpectation方法的具体用法?PHP SimpleExpectation::isExpectation怎么用?PHP SimpleExpectation::isExpectation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleExpectation
的用法示例。
在下文中一共展示了SimpleExpectation::isExpectation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertEltByIdHasAttrOfValue
function assertEltByIdHasAttrOfValue($eltId, $attrName, $attrValueExpected = true)
{
$matches = array();
$haystack = $this->getBrowser()->getContent();
// preg_match('/(\<[^\>]\s+id\s*=\s*"'.$eltId.'"\s+[^\>]*\>)/',$this->getBrowser()->getContent(),$matches);
preg_match('/(\\<[^\\>]*\\s+id\\s*=\\s*"' . $eltId . '"\\s*[^\\>]*\\>)/', $haystack, $matches);
// echo $matches[1];
if (!$this->assertTrue(isset($matches[1]), "Element with id [{$eltId}] should exist")) {
return false;
}
$haystack = $matches[1];
$matches = array();
preg_match('/\\s+(' . $attrName . ')\\s*=\\s*"([^"]*)"/', $haystack, $matches);
if (!$this->assertTrue(isset($matches[1]) && isset($matches[2]), "Element with id [{$eltId}] should have attribute of [{$attrName}]")) {
return false;
}
if ($attrValueExpected === true) {
return true;
}
if (!SimpleExpectation::isExpectation($attrValueExpected)) {
$attrValueExpected = new IdenticalExpectation($attrValueExpected);
}
$haystack = $matches[2];
if ($attrValueExpected->test($haystack)) {
return true;
}
return $this->assert($attrValueExpected, $haystack, "Element with id [{$eltId}] attribute [{$attrName}] value does not match- " . $attrValueExpected->testMessage($haystack));
}
示例2: _coerceToExpectation
function _coerceToExpectation($expected)
{
if (SimpleExpectation::isExpectation($expected)) {
return $expected;
}
return new IdenticalExpectation($expected);
}
示例3: assertCookie
/**
* Checks that a cookie is set for the current page
* and optionally checks the value.
* @param string $name Name of cookie to test.
* @param string $expected Expected value as a string or
* false if any value will do.
* @param string $message Message to display.
* @return boolean True if pass.
* @access public
*/
function assertCookie($name, $expected = false, $message = '%s')
{
$value = $this->getCookie($name);
if (!$expected) {
return $this->assertTrue($value, sprintf($message, "Expecting cookie [{$name}]"));
}
if (!SimpleExpectation::isExpectation($expected)) {
$expected = new EqualExpectation($expected);
}
return $this->assert($expected, $value, "Expecting cookie [{$name}] -> {$message}");
}
示例4: expectException
/**
* Sets up an expectation of an exception.
* This has the effect of intercepting an
* exception that matches.
* @param SimpleExpectation $expected Expected exception to match.
* @param string $message Message to display.
* @access public
*/
function expectException($expected = false, $message = '%s')
{
if ($expected === false) {
$expected = new AnythingExpectation();
}
if (!SimpleExpectation::isExpectation($expected)) {
$expected = new ExceptionExpectation($expected);
}
$this->expected = $expected;
$this->message = $message;
}
示例5: coerceToExpectation
/**
* Turns an expected exception into a SimpleExpectation object.
* @param mixed $exception Exception, expectation or
* class name of exception.
* @return SimpleExpectation Expectation that will match the
* exception.
*/
private function coerceToExpectation($exception)
{
if ($exception === false) {
return new AnythingExpectation();
}
if (!SimpleExpectation::isExpectation($exception)) {
return new ExceptionExpectation($exception);
}
return $exception;
}