Issues

ZF-7580: Zend_Test_PHPUnit_ControllerTestCase doesn't correct work with Zend_Navigation

Description

Create Zend_Navigation:


...
protected function _initMenu()
    {
        $view = $this->getResource('view');
        $pages = array(
            array (
                'controller' => 'user',
                'action'     => 'login',
                'label'      => 'Login',
            ),
            array (
                'controller' => 'user',
                'action'     => 'profile',
                'label'      => 'Profile',
            ),
        );

        $container = new Zend_Navigation($pages);
        $view->navigation($container);
        return $container;
    }
...

This menu is displaying in layout:


<?php echo $this->navigation()->menu(); ?>

Now, create unit test:


    function testGuestProfile()
    {
        $this->request->setMethod('GET');
        $this->dispatch('/user/login');
        $this->assertQueryContentContains('.navigation li.active a', "Login");
        $this->assertNotQueryContentContains('.navigation li.active a', "Profile");
        $this->resetRequest()
             ->resetResponse();
        $this->dispatch('/user/profile');
        //var_dump($this->getResponse()->getBody());
        $this->assertNotQueryContentContains('.navigation li.active a', "Login");
        $this->assertQueryContentContains('.navigation li.active a', "Profile");
    }

Result: {quote} Failed asserting node DENOTED BY .navigation li.active a DOES NOT CONTAIN content "Login" {quote}

Commented var_dump returns:


Login Profile

It seems as Zend_Navigation store stats from previous request and doesn't reset it. The example is trivial, but in real application problem is much complex (acl permissions aren't applied to new request, if I have resources for Zend_Navigation and so forth)

This problem exists only in Zend_Test_PHPUnit environment, so, it doesn't related with Zend_Navigation (that works fine in browser). And in my vision $this->resetRequest() ->resetResponse(); should reset state of initiated resources.

Comments

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.