Precisa de ajuda para o teste da unidade zend

Estou usando teste de unidade para testar o projeto zend, isto é application.ini

[production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 resources.frontController.params.displayExceptions = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" ; modules resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.moduleControllerDirectoryName = "controllers" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules[] = "" resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" resources.layout.layout = "layout" resources.view[] = resources.view.doctype = "XHTML1_STRICT" ; database resources.db.adapter = "PDO_MYSQL" resources.db.params.dbname = "demodev" resources.db.params.password = "demo_core_pass" resources.db.params.username = "demo_core_user" resources.db.params.host = "localhost" resources.db.isDefaultTableAdapter = true ; session resources.session.save_path = APPLICATION_PATH "/../data/session" resources.session.use_only_cookies = true ;resources.session.remember_me_seconds = 10 [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 [amsterdam : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 

Este é o phpunit.xml:

   ./    ../application/  ../application/Bootstrap.php ../application/controllers/ErrorController.php ../application/        

Este é o bootstrap.php

 <?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'), get_include_path(), ))); require_once 'Zend/Application.php'; require_once 'ControllerTestCase.php'; //require_once 'MyApp.php'; 

este é o ControllerTestCase.php

 bootstrap = array($this,'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this->application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH.'/configs/application.ini'); $this->application->bootstrap(); } } 

Este é o IndexControllerTest.php

 <?php 

require_once ‘Zend / Test / PHPUnit / ControllerTestCase.php’; class IndexControllerTest estende ControllerTestCase {

 public function testHomePage() { $this->dispatch('/index'); $this->assertController('index'); $this->assertAction('menu'); } 

}

Quando eu vou na pasta de testes, execute o comando phpunit, isso me dá esse erro:

 D:\PHP\apache2\htdocs\demo_src\tests>phpunit PHPUnit 3.5.13 by Sebastian Bergmann. PHP Fatal error: Call to a member function hasResource() on a non-object in D:\ PHP\apache2\htdocs\demo_src\application\controllers\ErrorController.php on line 46 Fatal error: Call to a member function hasResource() on a non-object in D:\PHP\a pache2\htdocs\demo_src\application\controllers\ErrorController.php on line 46 

Como posso resolver este problema?

Quando eu altero IndexControllerTest como um teste, como:

 assertTrue(true); } } 

funciona, mas quando eu mudar para

 dispatch('/'); } } 

A linha 46 no ErrorController.php é:

 public function getLog() { $bootstrap = $this->getInvokeArg('bootstrap'); if (!$bootstrap->hasResource('Log')) {// this is line 46 return false; } $log = $bootstrap->getResource('Log'); return $log; } 

Ainda me dá o mesmo erro, qualquer sugestão?

Tente com esta class IndexControllerTest

 class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase { public function setUp() { $this->bootstrap = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); parent::setUp(); } public function testHomePage() { $params = array( 'action' => 'index', 'controller' => 'index', 'module' => 'default' ); $url = $this->url($this->urlizeOptions($params)); $this->dispatch($url); // assertions $this->assertModule($params['module']); $this->assertController($params['index']); $this->assertAction($params['action']); } }