Zend_Test: no default module installed for this application

UPDATE Dec 23

I had a problem when the Zend Framework complains about "There is no default module for this application." I did not use modules, and the main application is working fine.

I finally solved the problem using weierophinney.net

In your bootstrap, you need to set the controller directory minimally - make a call $this->frontController->addControllerDirectory(...)in your method appBootstrap(). I did not do this in my example, as my initialization plugin does something like this for me.

The problem is solved by adding below to setUp()

$this->getFrontController()->setControllerDirectory(APPLICATION_PATH . '/controllers');

But now I have other questions:

1. Why is this value not initialized application.ini?

In application.inii have

[production]
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

[testing : production]
// didn't change anything regarding modules nor controllers

2. controllerDirectory bootstrap.php unit test,

$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(APPLICATION_PATH . '/controllers');

, , - setUp(). ?

END UPDATE 23 Dec


, . . bootstrap.php ,

$front = Zend_Controller_Front::getInstance();
$front->setDefaultModule('default');

. bootstrap.php this

UPDATE: :

2 :

1) Application_Controller_Plugin_AclTest::testAccessToUnauthorizedPageRedirectsToLogin
Zend_Controller_Exception: No default module defined for this application

D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:391
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:204
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:244
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Front.php:954
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Test\PHPUnit\ControllerTestCase.php:205
D:\Projects\Tickle\tests\application\controllers\plugins\aclTest.php:6

2) Application_Controller_Plugin_AclTest::testAccessToAllowedPageWorks
Zend_Controller_Exception: No default module defined for this application

D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:391
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:204
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Dispatcher\Standard.php:244
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Controller\Front.php:954
D:\ResourceLibrary\Frameworks\PHPFrameworks\Zend\Test\PHPUnit\ControllerTestCase.php:205
D:\Projects\Tickle\tests\application\controllers\plugins\aclTest.php:16

UPDATE

public function setUp() {
  $front = Zend_Controller_Front::getInstance();
  $front->setDefaultModule('default');
}

1 .

public function testAccessToUnauthorizedPageRedirectsToLogin() { // this fails with exception "Zend_Controller_Exception: No default module defined for this application"
  $this->dispatch('/projects');
  $this->assertController('auth');
  $this->assertAction('login');
}

public function testAccessToAllowedPageWorks() { // this passes
  $auth = Zend_Auth::getInstance();
  $authAdapter = new Application_Auth_Adapter('jiewmeng', 'password');
  $auth->authenticate($authAdapter);

  $this->dispatch('/projects');
  $this->assertController('projects');
  $this->assertAction('index');
}
+3
2

, setUp().

$this->getFrontController()->setControllerDirectory(APPLICATION_PATH . '/controllers');

Tho ,

1. application.ini?

application.ini

[production]
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

[testing : production]
// didn't change anything regarding modules nor controllers

2. controllerDirectory bootstrap.php unit test,

$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(APPLICATION_PATH

. '/');

, , - setUp(). ?

+3

, . setUp(), . bootstrap , . :

if($this->getFrontController()->getParam('bootstrap') === null) {
    $this->getFrontController()->setParam('bootstrap', $app->getBootstrap());
}
+1

Source: https://habr.com/ru/post/1781607/


All Articles