How does this line work when the user is not logged in?

$this->_auth->getStorage()->read()->role

--
Hector


On Wed, Feb 24, 2010 at 6:36 AM, neographikal <[email protected]> wrote:

>
> 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. I think it is Zend_Auth but I have no clue
> how to fix it :)
>
> Thanks for the help!
> --
> View this message in context:
> http://n4.nabble.com/Zend-Auth-vs-Zend-Test-PHPUnit-tp1567531p1567531.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>

Reply via email to