views:

536

answers:

2

When I run phpunit to test my controller there always comes the message: Class Zend_Test_PHPUnit_Controller_TestCase could not be found ...

All require_once are executed and run without errors.

My files:

Test.php:

<?php

require_once 'bootstrap.php';

class indexTest extends Zend_Test_PHPUnit_ControllerTestCase
{
    protected function setUp ()
    {
        $this->bootstrap = array($this, 'appBootstrap');
        parent::setUp();
    }

    public function appBootstrap ()
    {
        $this->frontController->registerPlugin(new DemoApp_Controller_Plugin_Initialize('test', PROJECT_ROOT));
    }

    public function testIndex()
    {
        $this->dispatch('/');
        $this->assertController('login');
    }   
}

bootstrap.php:

<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../src/application/'));

set_include_path( APPLICATION_PATH . '/../library' . PATH_SEPARATOR .
        APPLICATION_PATH . '/modules' . PATH_SEPARATOR .
        APPLICATION_PATH . '/layouts' . PATH_SEPARATOR .
        get_include_path() );

require_once 'PHPUnit/Framework.php';     
require_once 'PHPUnit/Framework/TestSuite.php';    
require_once 'PHPUnit/TextUI/TestRunner.php';

error_reporting(E_ALL);

require_once APPLICATION_PATH . "/../library/Zend/Loader.php";
Zend_Loader::registerAutoload();

// Set up the config in the registry path relative to public/index.php
$config = new Zend_Config_Ini(APPLICATION_PATH . '/config.ini'); //, 'test'
Zend_Registry::set('config', $config);

/*// Set up the database in the Registry
$db = Zend_Db::factory($config->db);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
*/

// Set timezone
date_default_timezone_set("Europe/Berlin");
A: 

The most obvious first question is, what version of the Zend Framework source do have? It's in Zend/Version.php.

Alister Bulman
VERSION = '1.7.8';
+1  A: 

The class is not in your include path, Or, you don't have the class at all.
Steps to take:

  1. Find the class file
  2. Make sure the class is in your include path, including the auto_loader name parsing: Z_Y_YourClass will be looked at the include_path/Z/Y/YourClass.php

Good Luck

Itay Moav
The class is defined at the file: "ControllerTestCase.php"in 'APPLICATION_PATH . "/../library/Zend/Test/PHPUnit/'which is added to the include path in bootstrap.php
Try for the experiment to use absolute paths and see what happens.
Itay Moav