這是一個非常具體的問題,我已經搜索了很多潛在的解決方案,但沒有指出我在正確的方向。我寫了一個Zend_Controller_Action_Helper來幫助我在應用程序中處理一些表單。現在在應用程序中,它工作正常,但它打破了我的測試。如果我註釋掉將助手添加到代理中的所有行都可以正常工作,但這樣會使對象失敗。我得到的錯誤是Zend框架,HelperBroker PHPUnit測試
Fatal error: Class 'PHPUnit_Framework_Error_Notice' not found in /Users/chris/NetBeansProjects/myProject/library/ProcessForm.php on line 25
我不明白的是爲什麼它扔上線25這個錯誤是專門
public function processForm($aParam)
所以我想我應該粘貼一些代碼向你展示一些應用程序。我在我的應用程序,像這樣的引導添加該助手..
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initHelpers()
{
// If I comment out these lines it all works
require_once 'ProcessForm.php';
Zend_Controller_Action_HelperBroker::addHelper(
new ProcessForm()
);
}
}
我PHPUnit的引導文件看起來像這樣
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
protected $application;
public function setUp()
{
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
$this->getFrontController()->setParam('bootstrap', $this->application->getBootstrap());
}
public function appBootstrap()
{
$this->application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$this->application->bootstrap();
}
}
實際助手看起來像這樣
class ProcessForm extends Zend_Controller_Action_Helper_Abstract
{
/**
* @var Zend_Loader_PluginLoader
*/
public $pluginLoader;
/**
* Constructor: initialize plugin loader
*
* @return void
*/
public function __construct()
{
$this->pluginLoader = new Zend_Loader_PluginLoader();
}
public function processForm($aParam)
{
}
public function direct($aParam)
{
return $this->processForm($aParam);
}
}
2意見建議:因爲它似乎找不到'PHPUnit_Framework_Error_Notice',你檢查過該文件是否存在? (Zend/Test/PHPUnit/Framework/Error/Notice.php),錯誤似乎來自ProcessForm的構造函數。所以,也許在其他類中'$ this-> pluginLoader = new Zend_Loader_PluginLoader();' – Shikiryu 2010-10-21 10:27:55
它不存在於您建議的路徑中,但它是路徑中的PHPUnit的一部分 – Catharsis 2010-10-21 11:02:21