Zend_Test, Zend_Layout and the need to reset

In a recent Zend Framework project I’ve used Zend_Test to test the functioning of the website ‘as a whole’. So besides testing the separate (authorization) components, the website was tested in the same way a visitor would use it. This is especially useful for testing login scenarios, so I added the test below:

public function testLogoutShouldDenyAccess()

         // verify that profile page now doesn't contain login form
    $this->assertQueryCount('form#login', 0);

        // dispatch logout page

        // verify that profile now holds login form
    $this->assertQueryCount('form#login', 1);

This failed on the last assertQueryCount() which left me puzzled. Performing above steps manually seemed to work fine so I was overlooking something either in my app-code or the test-code.

Keep reading