Пример #1
0
    public function testShouldAllowMatchingOfAttributeValues()
    {
        $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>ZF Issue ZF-4010</title>
    </head>
    <body>
        <form>
            <fieldset id="fieldset-input"><legend>Inputs</legend>
                <ol>
                    <li><input type="text" name="input[0]" id="input-0" value="value1" /></li>
                    <li><input type="text" name="input[1]" id="input-1" value="value2" /></li>
                    <li><input type="text" name="input[2]" id="input-2" value="" /></li>
                </ol>
            </fieldset>
        </form>
    </body>
</html>';
        $assertion = new Core_Tests_PHPUnit_Constraint_DomQuery('input#input-0 @value', Core_Tests_PHPUnit_Constraint_DomQuery::ASSERT_CONTENT_CONTAINS, 'value1');
        $result = $assertion->evaluate($html);
        $this->assertTrue($result);
    }
 /**
  * Assert against XPath selection;
  * should contain no more than this number of nodes
  *
  * @param  string $path XPath path
  * @param  string $count Maximum number of nodes that should match
  * @param  string $message
  * @return void
  */
 public function assertXpathCountMax($path, $count, $message = '')
 {
     $this->_incrementAssertionCount();
     require_once 'Core/Tests/PHPUnit/Constraint/DomQuery.php';
     $constraint = new Core_Tests_PHPUnit_Constraint_DomQuery($path, __FUNCTION__, $count);
     $constraint->registerXpathNamespaces($this->_xpathNamespaces);
     $content = $this->response->outputBody();
     if (!$constraint->evaluate($content)) {
         $constraint->fail($path, $message);
     }
 }