2009年1月28日星期三

Re: [fw-mvc] Zend_Test isn't working with my application

After not receiving any answers I think, my Mail have been lost in some big
big e-mail accounts.
So I send it again. My problem is, that my application is giving me the
message "Zend_Controller_Exception: No default module defined for this
application" but I don't get why :/

Here are the listings again:

--------------------
phpunit.xml
--------------------

<phpunit>
<testsuite name="PEP Test Suite">
<directory>./</directory>
</testsuite>

<filter>
<whitelist>
<directory suffix=".php">../src/library/</directory>
<directory suffix=".php">../src/</directory>
<exclude>
<directory suffix=".phtml">../src/</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="./log/testdox.html" />
</logging>
</phpunit>

--------------------
TestHelper.php
--------------------

<?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);

--------------------
index.php
--------------------

<?php
/**
* Bootstrapping / Front settings
*
* @category N/a
* @package TrioIntranet
* @author Stefanie Zeiger <s.zeiger@trio-group.de>
* @copyright 2008 trio-interactive it services gmbh
* @license N/a
* @version $Id: index.php 193 2009-01-19 16:06:51Z zeiger $
* @link http://www.trio-interactive.de
*/

// error_reporting( E_ERROR | E_WARNING | E_PARSE | E_NOTICE );

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');

$http = new Zend_Http_Client();

// 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() );

}


--------------------
WeekplannerControllerTest.php
--------------------

<?php

require_once 'TestHelper.php';

class PPPService_WeekplannerControllerTest 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
* Needs assertion!!!!
*/

public function testSetTitle()
{
$this->view->placeholder('layoutTitle')->set("phpUnit Test Title for
PPPService");
$this->dispatch('pppservice/weekplanner');
}

public function testCurrentAction()
{
$this->dispatch('pppservice/weekplanner/current');
}
}


--------------------


Thanks for trying to help me!

With kind regards,

Steffi


-----
--
Stefanie Zeiger
angehende Medieninformatikerin (Bachelor BA)
s.zeiger@trio-group.de
--
View this message in context: http://www.nabble.com/Zend_Test-isn%27t-working-with-my-application-tp21628300p21701499.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: