Source for file dom_tester.php
Documentation is available at dom_tester.php
* @subpackage DomTestCase
* @author Perrick Penet <perrick@noparking.net>
* @version $Id: dom_tester.php 1637 2008-01-20 20:18:54Z pp11 $
* include SimpleTest files
require_once dirname(__FILE__
).
'/../web_tester.php';
require_once dirname(__FILE__
).
'/dom_tester/css_selector.php';
* Create a CSS Selector expectation
* @param DomDocument $_dom
* @param string $_selector
* Sets the dom tree and the css selector to compare against
* @param mixed $dom Dom tree to search into.
* @param string $selector Css selector to match element.
* @param string $message Customised message on failure.
$this->SimpleExpectation($message);
* Normalizes the selector. In particular, replaces single-quotes with
* @param string $selector Css selector to match element.
* @return string Normalized Css selector.
* Tests the expectation. True if it matches the
* @param mixed $compare Comparison value.
* @return boolean True if correct.
function test($compare) {
return (($this->_value ==
$compare) &&
($compare ==
$this->_value));
* Returns a human readable test message.
* @param mixed $compare Comparison value.
* @return string Description of success
$dumper =
&$this->_getDumper();
if ($this->test($compare)) {
return "CSS selector expectation [" .
$dumper->describeValue($this->_value) .
"]".
" using [" .
$dumper->describeValue($this->_selector) .
"]";
return "CSS selector expectation [" .
$dumper->describeValue($this->_value) .
"]".
" using [" .
$dumper->describeValue($this->_selector) .
"]".
$dumper->describeValue($compare) .
"] " .
$dumper->describeDifference($this->_value, $compare);
* Extend Web test case with DOM related assertions,
* CSS selectors in particular
* @param DomDocument $dom
$this->dom =
new DomDocument('1.0', 'utf-8');
$this->dom->validateOnParse =
true;
Documentation generated on Sun, 04 May 2008 09:21:26 -0500 by phpDocumentor 1.3.0