我正在使用 Zend_Test。下面是我的测试/bootstrap.php 文件:
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('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/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Ca_');
Zend_Controller_Action_HelperBroker::addPrefix('Ca_Controller_Action_Helper');
$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
'namespace' => "Social",
'basePath' => APPLICATION_PATH . "/../library",
));
$resourceLoader->addResourceType('facebook', 'Facebook/', 'Facebook');
这是我的测试类中的 setUp() 方法(扩展 Zend_Test_PHPUnit_DatabaseTestCase):
public function setUp()
{
$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$this->entityUser = new Ca_Model_Entity_User_Registered();
$a = $this->getAdapter();
$a->setFetchMode(Zend_Db::FETCH_OBJ);
$a->query("SET FOREIGN_KEY_CHECKS=0;");
parent::setUp();
}
现在,在运行单元测试时,我收到此特定代码行的以下错误:
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
$options = $bootstrap->getOptions();
致命错误:在非对象上调用成员函数 getOptions()
有谁知道是什么导致了这个问题以及我该如何解决它?
谢谢。