本文整理汇总了PHP中SimpleExpectation类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleExpectation类的具体用法?PHP SimpleExpectation怎么用?PHP SimpleExpectation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleExpectation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: __construct
public function __construct($artifact_id)
{
parent::SimpleExpectation();
$this->artifact_id = $artifact_id;
}
示例4: assert
/**
* Runs an expectation directly, for extending the tests with new expectation classes.
*
* @param SimpleExpectation $expectation Expectation subclass.
* @param mixed $compare Value to compare.
* @param string $message Message to display.
*
* @return bool True on pass
*/
public function assert($expectation, $compare, $message = '%s')
{
$message = $this->escapePercentageSignsExceptFirst($message);
if ($expectation->test($compare)) {
return $this->pass(sprintf($message, $expectation->overlayMessage($compare, $this->reporter->getDumper())));
} else {
return $this->fail(sprintf($message, $expectation->overlayMessage($compare, $this->reporter->getDumper())));
}
}
示例5: assert
/**
* Runs an expectation directly, for extending the
* tests with new expectation classes.
* @param SimpleExpectation $expectation Expectation subclass.
* @param mixed $compare Value to compare.
* @param string $message Message to display.
* @return boolean True on pass
* @access public
*/
function assert(&$expectation, $compare, $message = '%s') {
if ($expectation->test($compare)) {
return $this->pass(sprintf(
$message,
$expectation->overlayMessage($compare, $this->_reporter->getDumper())));
} else {
return $this->fail(sprintf(
$message,
$expectation->overlayMessage($compare, $this->_reporter->getDumper())));
}
}
示例6: 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;
}
示例7: checkExpectation
/**
* Runs an expectation directly, taking a possibly expected fail
* into account by turning the tables then.
* @param SimpleExpectation $expectation Expectation subclass.
* @param mixed $compare Value to compare.
* @return boolean True on pass / expected fail, false on fail / unexpected pass.
* @access public
*/
function checkExpectation($expectation, $compare)
{
$rv = $expectation->test($compare);
return $rv;
}
示例8: assertExpectation
/**
* Runs an expectation directly, for extending the
* tests with new expectation classes.
* @param SimpleExpectation $expectation Expectation subclass.
* @param mixed $test_value Value to compare.
* @param string $message Message to display.
* @return boolean True on pass
* @access public
*/
function assertExpectation(&$expectation, $test_value, $message = '%s')
{
return $this->assertTrue($expectation->test($test_value), sprintf($message, $expectation->overlayMessage($test_value)));
}
示例9: __construct
public function __construct(Tracker_Workflow_Trigger_TriggerRule $trigger_rule)
{
parent::SimpleExpectation();
$this->trigger_rule = $trigger_rule;
}
示例10: 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;
}
示例11: __construct
/**
* Sets the dom tree and the css selector to compare against
*
* @param mixed $dom Dom tree to search into.
* @param mixed $selector Css selector to match element.
* @param string $message Customised message on failure.
*/
public function __construct($dom, $selector, $message = '%s')
{
parent::__construct($message);
$this->dom = $dom;
$this->selector = $selector;
$css_selector = new CssSelector($this->dom);
$this->value = $css_selector->getTexts($this->selector);
}
示例12: __construct
public function __construct($expected_cn)
{
parent::__construct();
$this->expected = $expected_cn;
}
示例13: __construct
public function __construct($repository_id)
{
parent::__construct();
$this->repository_id = $repository_id;
}
示例14:
/**
* Stashes the method and expected count for later
* reporting.
* @param string $method Name of method to confirm against.
* @param integer $count Minimum number of calls.
* @param string $message Custom error message.
*/
function __construct($method, $count, $message = '%s')
{
$this->method = $method;
$this->count = $count;
parent::__construct($message);
}
示例15:
function __construct($expected, $message = '%s')
{
parent::__construct($message);
if (!is_object($expected)) {
trigger_error('Attempt to create a CheckSpecifiedFieldsExpectation ' . 'with an expected value that is not an object.');
}
$this->expect = $expected;
}