Bu sorunun cevabını Google'da ve sadakatsiz başka sitelerde saatlerce aradım. PHPUnit kullanarak Zend Framework projem için bazı birim testleri oluşturdum. Her şey, PHPUnit Kod Kapsamı raporunun noktasına kadar olan testlerle iyi gider.PHPUnit - Zend Framework uygulamasıyla ilgili Kod Kapsamı raporu oluşturma sorunu
Generating code coverage report, this may take a moment. Fatal error: Call to a member function pushStack() on a non-object in C:\htdocs\ZendFWTutorials\ZendStorefront\library\SF\Plugin\Action.php on line 32
Bu hata aşağıdaki kod bloğunu başvuruyor: Bu noktada aşağıdaki hatayı alıyorum
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;
}
Bu kod muhtemelen karmaşıklığını artırır Öyle yazmadım bir kütüphaneden olduğunu benim Sorun ne olup bittiğini anlamakta daha az olasıdır. Ben de PHPUnit mantığının kod kapsama raporunu oluştururken ne yaptığını bilmiyorum, bu yüzden sorunu nasıl çözeceğimi bilmiyorum. Bu sorun, yalnızca PHPUnit çalıştırdığımda ve normal çalışma koşullarında bu işlevdeki kodu izlemek için xdebug çalıştırdığımda oluşur. PHPUnit değişkeninin boş olduğu bir koşul girdiğine, ancak normal işlemde $ stack ve $ categoryRequest öğesinin boş olmadığına dair bir his var. aşağıdaki gibi
Benim dizin yapısı şöyledir:
./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();
Sorunu bir eklenti içinde keşfettim, düzeltme için aşağıda okuyun. – rossdh