Zend framework 使用Zend_测试引导Zend_应用程序

Zend framework 使用Zend_测试引导Zend_应用程序,zend-framework,zend-test,Zend Framework,Zend Test,在文档中,提供的引导代码如下所示 protected $application; public function setUp() { $this->bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this->application = new Zend_Application( ... ); $this->

在文档中,提供的引导代码如下所示

protected $application;
public function setUp() {
    $this->bootstrap = array($this, 'appBootstrap');
    parent::setUp();
}
public function appBootstrap() {
    $this->application = new Zend_Application( ... );
    $this->application->bootstrap();
}
我很好奇为什么我试了一下

protected $application;
public function setUp() {
    $this->application = new Zend_Application( ... );
    $this->application->bootstrap();
    parent::setUp();
}
它失败了。另外,当我尝试在bootstrap.php中移动引导应用程序时,它也失败了

// bootstrap.php
...
$application = new Zend_Application( ... );
$application->bootstrap();

我之所以想到将其移动到bootstrap.php,是因为扩展了ControllerTestCase,以便在一个单独的类中处理所有这些引导。我想与其扩展类,不如将代码移到bootstrap.php的1个位置,这样会更好吗

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

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