Reputation: 76
I am having trouble with an assertQuery(). In the html I have (verified by outputting the body)
<input type="text" name="LASTNAME" id="LASTNAME" value="" maxlength="25" size="20" />
So I wrote a query for it to test to make sure this element exists and that the value is empty
$this->assertQuery('input#LASTNAME[value=""]', 1);
PhpUnit says the assertion fails
Failed asserting node DENOTED BY input#LASTNAME[value=""] EXISTS
Can you give me some insight into why this assertion fails and how to write it properly?
Thanks in advance!
Upvotes: 2
Views: 2070
Reputation: 3285
Alternatively, you could use XPath
instead of CSS
selectors, and thus skip the CSS
to XPath
conversion performed by Zend_Dom_Query
:
$this->assertXpath( '//input[@id="LASTNAME"][@value=""]' );
Upvotes: 1
Reputation: 36562
Zend Framework's code that converts the CSS selector to an XPath query is broken. It doesn't add the required @
before the attribute name. Use this, albeit incorrect CSS, assertion:
$this->assertQuery('input#LASTNAME[@value=""]', 1);
See this forum thread for details.
Update: The issue was reported and fixed in release 1.10, so you could upgrade your Zend Framework as an alternative to using an invalid CSS selector.
Upvotes: 4