You are not logged in.
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:8Does 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 ![]()
Thanks for the help!
Offline
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