正在生成代码覆盖率报告,请稍等片刻。致命错误:在C:\htdocs\ZendFWTutorials\ZendStorefront\library\SF\Plugin\Action.php的第32行中,调用非对象成员函数pushStack()。
这个错误是指以下代码块:
public function
dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$stack = $this->getStack();
// category menu
$categoryRequest = new Zend_Controller_Request_Simple();
$categoryRequest->setControllerName('category')
->setActionName('index')
->setParam('responseSegment', 'categoryMain');
// push requests into the stack
$stack->pushStack($categoryRequest);
}
public function getStack()
{
if (null === $this->_stack) {
$front = Zend_Controller_Front::getInstance();
if (!$front->hasPlugin('Zend_Controller_Plugin_ActionStack'))
{
$stack = new Zend_Controller_Plugin_ActionStack();
$front->registerPlugin($stack);
} else {
$stack = $front->getPlugin('ActionStack');
}
$this->_stack = $stack;
}
return $this->_stack;
}
这段代码来自于我没有编写的一个库,所以可能会增加一些复杂性,因为我不太可能理解正在发生的事情。我也不知道 PHPUnit 的逻辑在创建代码覆盖报告时做了什么,所以我不知道如何解决这个问题。只有当我运行PHPUnit并且在正常操作条件下跟踪此函数中的代码时,才会出现此问题。我有一种感觉,PHPUnit进入了一个变量为空的条件,但在正常操作中,$stack和$categoryRequest不为空。
我的目录结构如下:
application
----->bootstrap
----->config
----->layouts
----->modules
-------->storefront
-------------->controllers
-------------->forms
-------------->models
-------------->services
-------------->views
build
data
library
----->SF
----->Zend
Public
----->css
----->images
tests
----->application
------------->modules
------------->controllers
------------->models
----TestHelper.php
----phpunit.xml
phpunit.xml 如下:
./application/
<filter> <whitelist> <directory suffix=".php">../application/</directory> <exclude> <directory suffix=".phtml">../application/</directory> <directory suffix=".php">../library/</directory> </exclude> </whitelist> </filter> <logging> <log type="coverage-html" target="./log/report" charset="UTF-8" yui="true" highlight="true" lowUpperBound="50"
highLowerBound="80"/>
TestHelper.php:
<?php // set our app paths and
environments define('BASE_PATH',
realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_PATH', BASE_PATH .
'/application'); define('TEST_PATH',
BASE_PATH . '/tests');
define('APPLICATION_ENV', 'testing');
//include path set_include_path('.' .
PATH_SEPARATOR . BASE_PATH .
'/library' . PATH_SEPARATOR .
get_include_path());
// set the default timezone
date_default_timezone_set('America/Argentina/Buenos_Aires');
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/config/store.ini');
$application->bootstrap();