According to this mailing list discussion, the recommended way to access the application resources in a Zend MVC controller is:
$this->getInvokeArg('bootstrap')->getResource('foo');
This works in production (when browsing to the corresponding Web page). However, when testing a controller action containing this code with Zend_Test_PHPUnit_ControllerTestCase
, I get:
PHP Fatal error: Call to a member function getResource() on a non-object in .../application/controllers/IndexController.php on line 12
Until introducing that getInvokeArg
thing, the tests ran just fine. The question is, how can I make the “recommended” way of accessing resources work in the test harness?
Just checked: $this->getFrontController()->getParam('bootstrap')->getResource('foo')
doesn't work either.
UPDATE: I do call the application bootstrap with phpunit --bootstrap ./scripts/application_bootstrap.php ...
and I know it executes fine.
And there I have:
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();