Also includes various helper methods.
 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));
 }
 function _coerceToExpectation($expected)
 {
     if (SimpleExpectation::isExpectation($expected)) {
         return $expected;
     }
     return new IdenticalExpectation($expected);
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 public function __construct($expected_cn)
 {
     parent::__construct();
     $this->expected = $expected_cn;
 }
 public function __construct($artifact_id)
 {
     parent::SimpleExpectation();
     $this->artifact_id = $artifact_id;
 }
Example #6
0
 /**
  * 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())));
     }
 }
Example #7
0
 /**
  *    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())));
     }
 }
 public function __construct($repository_id)
 {
     parent::__construct();
     $this->repository_id = $repository_id;
 }
Example #9
0
 /**
  *    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);
 }
 /**
  *    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;
 }
 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;
 }
Example #12
0
 /**
  *    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;
 }
Example #13
0
 public function __construct($expected_field_data)
 {
     parent::__construct();
     $this->expected_field_data = $expected_field_data;
 }
 function __construct(array $expected)
 {
     parent::__construct();
     $this->expected = $expected;
 }
 public function __construct(array $should_not_exist)
 {
     parent::__construct();
     $this->should_not_exist = $should_not_exist;
 }
Example #16
0
 /**
  *    Sets the value to compare against.
  *    @param string $method     Method to check.
  *    @param string $message    Customised message on failure.
  *    @return void
  */
 function __construct($method, $message = '%s')
 {
     parent::__construct($message);
     $this->method =& $method;
 }
 /**
  * Creates a new IdenticalBinaryExpectation comparing with $left.
  * @param string $left    hand side of comparison
  * @param string $message for expecation
  */
 public function __construct($left, $message = '%s')
 {
     parent::__construct($message);
     $this->_left = $left;
 }
Example #18
0
 /**
  *    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)));
 }
Example #19
0
 public function __construct(Tracker_Workflow_Trigger_TriggerRule $trigger_rule)
 {
     parent::SimpleExpectation();
     $this->trigger_rule = $trigger_rule;
 }
 /**
  *    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;
 }
Example #21
0
 /**
  *    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.
  *    @access public
  */
 function assertExpectation(&$expectation, $test_value, $message)
 {
     $this->assertTrue($expectation->test($test_value), sprintf($message, $expectation->testMessage($test_value)));
 }
Example #22
0
 /**
  * __construct method
  *
  * @param string $key
  * @param string $value
  */
 function __construct($key, $value)
 {
     parent::SimpleExpectation('%s');
     $this->_expected = compact('key', 'value');
 }
Example #23
0
 /**
  *    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')
 {
     return $this->assertTrue($expectation->test($compare), sprintf($message, $expectation->overlayMessage($compare)));
 }
Example #24
0
 /**
  *    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}");
 }
Example #25
0
 /**
  *    Sets the value to compare against.
  *    @param string $string    Pattern to search for.
  *    @param string $message    Customised message on failure.
  *    @access public
  */
 public function __construct($string, $message = '%s')
 {
     parent::__construct($message);
     $this->string = $string;
 }