views:

27

answers:

2

I am currently trying to write some unit test against my zend framework controller. When I run the following code I receive this error:

public function testListActionShouldContainListTable()
    {

        $this->loginToSystem();

        $uri = $this->_uriBase . 'campaign/list';
        $_SERVER["REQUEST_URI"] = $uri;

        $this->dispatch('/campaign/list');
        $this->assertController('campaign');
        $this->assertAction('list');
        $this->assertQueryCount('#list',1);
    }


CampaignControllerTests::testListActionShouldContainListTable
DOMDocument::loadHTML(): ID alrt already defined in Entity, line: 36

This occurs using any of the assertQuery and assertQueryContains methods. I have searched around but am not really finding a good answer to why it won't allow me to find this html node or how to get around this error.

Thanks in advance for any help!

A: 

The HTML being generated by the dispatch is bad (it looks like it has two ids being assigned to a single tag). This is not an error of your test (it's working fine), it's an error in your html output generated by the test...

ircmaxell
i have done an echo of $this->getResponse->outputBody() and getBody() and can find no duplicates for the id. I have tried css searches for just "body", "div" as well as xpath searches and they all production the same error. Right time i remove the assertQuery call, the tests pass.
ranhan
Look for either more than 1 element with the same id, or an element with more than 1 id attribute...
ircmaxell
Thanks you were right. It only took 2 times going through the mark up before I stopped overlooking the dup id.
ranhan
+1  A: 

Make sure the document is valid. You have duplicate IDs in your HMTL document.

racetrack