Zendcasts Forum

A community of developers who work with the Zend Framework and other enterprise PHP technologies

You are not logged in.

#1 2010-02-19 08:33:41

neographikal
New member
Registered: 2010-01-04
Posts: 2

Integration of Zend_Navigation breaks unit test script

I have used the code from ZC to setup my unit-testing environment and it worked like a charm, untill I integrated Zend_Navigation with my application. My unit tests fail if I have this line of code in my application/bootstrap.php:

$view->navigation()->setAcl($this->_acl)->setRole($this->_auth->getStorage()->read()->role);

Whole function in bootstrap.php:

    protected function _initControllerPlugins() {
        $this->bootstrap('layout');
        $layout = $this->getResource('layout');
        $view = $layout->getView();
        $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');

        $container = new Zend_Navigation($config);
        $view->navigation($container);
        $view->navigation()->setAcl($this->_acl)->setRole($this->_auth->getStorage()->read()->role);
   
        $frontController->registerPlugin(new App_Plugin_AuthControllerPlugin($this->_acl, $this->_auth, $config, $view));
    }
}

Error from phpunit:

18) App_Service_UserServiceTest::testUserServiceLogout
Trying to get property of non-object

/var/www/dev.campingadministratie.nl/application/Bootstrap.php:55
/var/www/phpincludes/Zend-1.10.1/Application/Bootstrap/BootstrapAbstract.php:665
/var/www/phpincludes/Zend-1.10.1/Application/Bootstrap/BootstrapAbstract.php:618
/var/www/phpincludes/Zend-1.10.1/Application/Bootstrap/BootstrapAbstract.php:582
/var/www/phpincludes/Zend-1.10.1/Application.php:355
/var/www/dev.campingadministratie.nl/tests/application/ControllerTestCase.php:19
/var/www/phpincludes/Zend-1.10.1/Test/PHPUnit/ControllerTestCase.php:149
/var/www/phpincludes/Zend-1.10.1/Test/PHPUnit/ControllerTestCase.php:127
/var/www/dev.campingadministratie.nl/tests/application/ControllerTestCase.php:14
/var/www/dev.campingadministratie.nl/tests/library/App/Service/UserServiceTest.php:8

Does anyone have an idea how to solve this problem? In my normal environment, everything works like a charm, but with the unit tests that one line of code breaks everything smile

Thanks for the help!

Offline

#2 2010-02-22 14:37:21

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: Integration of Zend_Navigation breaks unit test script

Zend_Auth out of the box relies on sessions... which don't work properly when you're unit testing... that would be my first guess!

Offline

Board footer

Powered by FluxBB