Zend Framework

CSS and XPath assertions/queries do not work when document begins with XML declaration

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.9.1
  • Fix Version/s: None
  • Labels:
    None

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"]');

Issue Links

Activity

Hide
Benjamin Eberlei added a comment -

Could you maybe investigate if this is a problem with Zend_Dom_Query instead?

Show
Benjamin Eberlei added a comment - Could you maybe investigate if this is a problem with Zend_Dom_Query instead?
Hide
Wojciech Szela added a comment -

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.

Show
Wojciech Szela added a comment - 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.
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: