2

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!

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Very nice and complete answer :)
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.