Good morning everybody!
I've got a problem which is bothering me for days. I wrote tests and
everything is going fine. But suddenly one test failed with the message
"Zend_Controller_Exception: No default module defined for this application".
This is the code of my test:
public function testNewAction()
{
$this->dispatch('pppservice/requisition/new');
$request = $this->getRequest();
$request->setMethod('POST');
$this->view->placeholder('layoutTitle')->set("phpUnit Test Title for
PPPService");
$this->dispatch('pppservice/requisition/new');
$request->setPost( array(
'step' => ''
));
$this->dispatch('pppservice/requisition/new');
$request->setPost( array(
'step' => 'custom'
));
$this->dispatch('pppservice/requisition/new');
}
I figured out, that this message is only thrown when
$request->setMethod('POST'); is active. But in an other test I only have
written
public function testCurrentAction()
{
$this->dispatch('pppservice/weekplanner/current');
}
and there is the same error.
I tried to add
$this->fail(var_export($this->frontController->getControllerDirectory(),
1)); to the failing test and the message I get is:
1) testNewAction(PPPService_RequisitionControllerTest)
array (
'pppservice' =>
'/home/zeiger/public_html/TrioIntranet/PEP/src/intranet/modules/pppservice/controllers',
'dashboard' =>
'/home/zeiger/public_html/TrioIntranet/PEP/src/intranet/modules/dashboard/controllers',
)
/home/zeiger/public_html/TrioIntranet/PEP/tests/intranet/modules/pppservice/controllers/RequisitionControllerTest.php:94
I hope someone of you can help me - I think I'm getting crazy sitting day by
day at this problem :/
I don't know if it can help solve the problem, but here is the bootstrap
file and after it there is my testHelper file and the testfile:
index.php
header('content-type: text/html; charset=UTF-8');
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) .
'/library');
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
// start session
Zend_Session::start();
// get the front controller
$front = Zend_Controller_Front::getInstance();
// set up this app as modular one
$front->addModuleDirectory(dirname(__FILE__) . '/intranet/modules');
// FOR DEVELOPMENT ONLY
$front->throwExceptions(true);
// start Zend_Layout
Zend_Layout::startMvc(array(
'layout' => 'default'
, 'layoutPath' => dirname(__FILE__) . '/intranet/layout/scripts'
));
// fill the registry with some useful data
Zend_Registry::set('mandants', new Zend_Config_Ini(dirname(__FILE__) .
'/intranet/config/application.ini', 'mandants'));
Zend_Registry::set('dbh-maindb',
Zend_Db::factory(new Zend_Config_Ini(dirname(__FILE__) .
'/intranet/config/application.ini', 'maindb-dev')));
Zend_Registry::set('dbh-staffdb',
Zend_Db::factory(new Zend_Config_Ini(dirname(__FILE__) .
'/intranet/config/application.ini', 'staffdb-dev')));
Zend_Registry::set('basePath', dirname($_SERVER['PHP_SELF']));
// pre-configure the table data gateway
Zend_Db_Table_Abstract::setDefaultAdapter('dbh-maindb');
// configure router
$front->getRouter()->addRoute('default',
new Zend_Controller_Router_Route(':module/:controller/:action/*',
array(
'module' => 'dashboard'
, 'controller' => 'index'
, 'action' => 'index'
)
));
// now dispatch
try {
$front->dispatch();
} catch(Exception $e) {
throw $e;
## THIS IS ONLY FOR DEVELOPMENT USE!
#echo nl2br( $e->__toString() );
}
testHelper.php
/*
* Start output buffering
*/
ob_start();
/*
* Set error reporting to the level to which code must comply.
*/
error_reporting( E_ALL | E_STRICT );
/*
* Set default timezone
*/
date_default_timezone_set('GMT');
/*
* Testing environment
*/
define('APPLICATION_ENV', 'testing');
/*
* Determine the root, library, tests, and models directories
*/
$root = realpath(dirname(__FILE__) . '/../');
$library = $root . '/library';
$tests = $root . '/tests';
$modules = $root . '/src/intranet/modules/';
/*
* Prepend the library/, tests/, and models/ directories to the
* include_path. This allows the tests to run out of the box.
*/
$path = array(
$modules,
$library,
$tests,
get_include_path()
);
set_include_path(implode(PATH_SEPARATOR, $path));
/**
* Register autoloader
*/
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
/**
* Store application root in registry
*/
Zend_Registry::set('testRoot', $root);
Zend_Registry::set('testBootstrap', $root . '/src/index.php');
// get the front controller
$front = Zend_Controller_Front::getInstance();
// set up this app as modular one
$front->addModuleDirectory(dirname(__FILE__) . '/intranet/modules');
$front->setDefaultModule('dashboard');
$front->setControllerDirectory(
array(
'default' => dirname(__FILE__) .
'/intranet/modules/dashboard/controllers',
'dashboard' => dirname(__FILE__) .
'/intranet/modules/dashboard/controllers',
'pppservice' => dirname(__FILE__) .
'/intranet/modules/pppservice/controllers'
)
);
/*
* Unset global variables that are no longer needed.
*/
unset($root, $library, $tests, $path);
RequisitionControllerTest.php
require_once 'TestHelper.php';
class PPPService_RequisitionControllerTest extends
Zend_Test_PHPUnit_ControllerTestCase {
/*
* Sets up the bootstrap.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
$this->view = new Zend_View_Helper_Placeholder();
$this->bootstrap = Zend_Registry::get('testBootstrap');
return parent::setUp();
}
/**
* Tests setting title of page
*/
public function testSetTitle()
{
$this->view->placeholder('layoutTitle')->set("phpUnit Test Title for
PPPService");
$this->dispatch('pppservice/requisition');
}
/**
* test actions of list action
*/
public function testListAction()
{
$this->dispatch('pppservice/requisition/list');
//begin checking form
$request = $this->getRequest();
$request->setMethod('POST');
//test form validation
$request->setPost( array(
'jobnumber' => 'wrongNumber',
'accountExecutive' => 'someone',
'calendarweek' => '52/2008'
));
$this->dispatch('pppservice/requisition/list');
//test "Zurücksetzen" Button
$request->setPost(array(
'Zurücksetzen' => 'Zurücksetzen',
));
$this->dispatch('pppservice/requisition/list');
//test data getter and setter and optional data
$request->setParams(array(
'jobnumber' => 'TRIA102-001',
'accountExecutive' => 'Mo',
'calendarweek' => '2008-50'
));
$request->setPost(array(
'Zurücksetzen' => '',
'jobnumber' => 'TRIA101-001',
'accountExecutive' => 'Me',
'calendarweek' => '2008-52',
'orderedby' => 'jobnumber',
'direction' => 'asc'
));
$this->dispatch('pppservice/requisition/list');
}
public function testEditAction()
{
$this->view->placeholder('layoutTitle')->set("phpUnit Test Title for
PPPService");
$this->dispatch('pppservice/requisition/edit');
$request = $this->getRequest();
$request->setMethod('POST');
$request->setParam('id', 1);
$request->setPost( array(
'jobnumber' => 'TRIA102-001',
));
$this->dispatch('pppservice/requisition/edit');
$request->setPost( array(
'lastProcessor' => '1',
));
$this->dispatch('pppservice/requisition/edit');
}
public function testNewAction() // the test which is not
working after $request->setMethod('POST');
{
$this->dispatch('pppservice/requisition/new');
$request = $this->getRequest();
$request->setMethod('POST');
$this->view->placeholder('layoutTitle')->set("phpUnit Test Title for
PPPService");
$this->dispatch('pppservice/requisition/new');
$request->setPost( array(
'step' => ''
));
$this->dispatch('pppservice/requisition/new');
$request->setPost( array(
'step' => 'custom'
));
$this->dispatch('pppservice/requisition/new');
}
}
Thank you for trying to help me!
With kind regards,
Steffi
--
View this message in context:
http://www.nabble.com/Zend_Test%3A-No-default-module-defined-for-this-application-tp20911234p20911234.html
Sent from the Zend Framework mailing list archive at Nabble.com.