ZF-7564: CSS and XPath assertions/queries do not work when document begins with XML declaration
Description
The following test fails:
class MyTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function testFoo()
{
$this->dispatch('/');
$this->assertQuery('form#foo');
}
}
when requested document begins with XML declaration:
<?xml version="1.0" encoding="UTF-8" ?>
and passes if there is no such declaration.
What is more interesing
$this->assertQuery('#foo');
passes. Same applies to corresponding XPath queries (CSS queries are translated into XPath queries):
$this->assertXpath('//form[@id="foo"]');
fails, but the following passes
$this->assertXpath('//*[@id="foo"]');
Comments
Posted by Benjamin Eberlei (beberlei) on 2009-09-18T01:18:24.000+0000
Could you maybe investigate if this is a problem with Zend_Dom_Query instead?
Posted by Wojciech Szela (wojciech.szela) on 2009-09-23T09:35:37.000+0000
Yes, the bug itself is in Zend_Dom_Query component, but since Zend_Test_PHPUnit is using it, both components are affected. Anyway, the query component should be fixed.
Posted by Matthew Weier O'Phinney (matthew) on 2010-01-21T09:28:12.000+0000
I've tried a number of documents with the XML declaration, and in all cases, the queries you specified worked fine -- both the CSS selector and XPath queries.
If you can provide sample content and queries that fail, please re-open this issue or open a new one.