I think the best way is to create a little PHP Script to initialize your unit tests, and I do the following:
In my phpunit.xml / bootstrap = "./initalize.php"
initalize.php
define('BASE_PATH', realpath(dirname(__FILE__) . '/../')); define('APPLICATION_PATH', BASE_PATH . '/application'); // Include path set_include_path( '.' . PATH_SEPARATOR . BASE_PATH . '/library' . PATH_SEPARATOR . get_include_path() ); // Define application environment define('APPLICATION_ENV', 'testing'); require_once 'BaseTest.php';
BaseTest.php
abstract class BaseTest extends Zend_Test_PHPUnit_ControllerTestCase { public $application; public function setUp() { $session = new Zend_Session_Namespace(); $this->application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); $this->bootstrap = array($this, 'appBootstrap'); Zend_Session::$_unitTestEnabled; parent::setUp(); } public function appBootstrap() { $this->application->bootstrap(); } }
All my unit tests extend the BaseTest class, it works like a charm.
source share