Bootstrapping Zend_Application with Zend_Test
in the docs the provided code for bootstrapping looks like
protected $application;
public function setUp() {
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
}
public function appBootstrap() {
$this->application = new Zend_Application( ... );
$this->application->bootstrap();
}
i was curious why when i tried
protected $application;
public function setUp() {
$this->application = new Zend_Application( ... );
$this->application->bootstrap();
parent::setUp();
}
it failed. also when i tried moving bootstrapping the application in bootstrap.php it fails too
// bootstrap.php
...
$application = new Zend_Application( ... );
$application->bootstrap();
the reason why i thought of moving this to bootstrap.php is jon lebensold f开发者_高级运维rom zend casts extended the ControllerTestCase to handle all this bootstrapping in a separate class. i thought instead of extending the class, if i can move the code into the bootstrap.php in 1 place wont it be better
This is what my ControllerTestCase.php looks like:
<?php
abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
parent::setUp();
}
}
TestHelper.php (Bootstrap)
<?php
define('BASE_PATH', realpath(dirname(__FILE__) . '/../public'));
define('APPLICATION_PATH', realpath(BASE_PATH . '/../application'));
set_include_path(implode(PATH_SEPARATOR, array(
'.',
realpath(APPLICATION_PATH . '/../library'),
get_include_path()
)));
define('APPLICATION_ENV', 'testing');
require_once "Zend/Loader/Autoloader.php";
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);
require_once 'ControllerTestCase.php';
精彩评论