Getting a "No default module defined for this application" exception while running controller unit t

Posted by Doron on Stack Overflow See other posts from Stack Overflow or by Doron
Published on 2010-03-24T13:32:04Z Indexed on 2010/03/24 15:43 UTC
Read the original article Hit count: 373

Filed under:
|
|

I have an application with the default directory structure, for an application without custom modules (see structure figure at the end).

I have written a ControllerTestCase.php file as instructed in many tutorials, and I've created the appropriate bootstrap file as well (once again, see figures at the end).

I've written some model tests which run just fine, but when I started writing the index controller test file, with only one test in it, with only one line in it ("$this->dispatch('/');"), I'm getting the following exception when running phpunit (but navigating with the browser to the same location - all is good and working):

1) IndexControllerTest::test_indexAction_noParams
Zend_Controller_Exception: No default module defined for this application

Why is this ? What have I done wrong ?

Appendixes:
Directory structure:

-proj/
  -application/
    -controllers/
      -IndexController.php
      -ErrorController.php
    -config/
    -layouts/
    -models/
    -views/
      -helpers/
      -scripts/
        -error/
          -error.phtml
        -index/
          -index.phtml
    -Bootstrap.php
  -library/
  -tests/
    -application/
      -controllers/
        -IndexControllerTest.php
      -models/
      -bootstrap.php
      -ControllerTestCase.php
    -library/
    -phpunit.xml
  -public/
    -index.php

(Basically I have some more files in the models directory, but that's not relevant to this question.)

application.ini file:

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "My"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view[] = 
phpSettings.date.timezone = "America/Los_Angeles"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

tests/application/bootstrap.php file

<?php 
error_reporting(E_ALL);
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'), // this project' library
    get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

require_once 'ControllerTestCase.php';

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about phpunit