Empty $_controllerDirectory array (from Zend_Controller_Dispatcher_Standard) during phpunittest
I am trying run phpUnitTest (3.5.4) with Zend_Framework (v 1.10.8) and still receive
Zend_Controller_Exception: No default module defined for this application
for example test of class AuthControllerTest which extends Zend_Test_PHPUnit_ControllerTestCase
/** * @test */ public function
loginPage() {
$this->dispatch('/login');
$this->assertController('auth');
$this->assertAction('login'); }
After debug I found that variable $_controllerDirectory in Zend_Controller_Dispatcher_St开发者_如何学运维andard is empty. Normally it contains:
array 'Default' => string 'C:\x\phpcode\application/modules\Default\controllers'
I have defined router
<loginPage>
<route>login</route>
<defaults>
<module>default</module>
<controller>auth</controller>
<action>login</action>
</defaults>
<map>
</map>
<reverse>login</reverse>
</loginPage>
and other FC params
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.baseUrl = "http://www.fff44.pl:8080/"
resources.frontController.defaultController = "index"
resources.frontController.defaultAction = "index"
resources.frontController.defaultModule = "default"
what could be wrong?
do you use zend_application?
my solution:
protected function _setUp ()
{
// your Zend_Application instance from your own test-bootstrap file
$application = Zend_Registry::get('application');
if ($this->bootstrap === null) {
$this->bootstrap = new Zend_Application (
$application->getEnvironment(),
$application->getOptionsFile(),
$application->getDefaultsFile()
);
}
parent::_setUp();
}
精彩评论