2015-09-04 53 views
0

我正在使用phpunit在magento項目中進行測試。 的問題是,我得到這個目錄內的Magento:警告包括Magento項目中的TestCase phpunit

magento/ 
-tests/ 
--integration/bootstrap.php 
---Training/ 
----Example/ 
-----Helper/DataTest.php 

所以,我得到了bootstrap.php中,這個文件裏面我關掉警告,我的測試:

require_once __DIR__ . '/../../app/Mage.php'; 
Mage::setIsDeveloperMode(true); 
Mage::app(); 

$handler = set_error_handler(function() {}); 
set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($handler) 
{ 
    if (E_WARNING === $errno 
     && 0 === strpos($errstr, 'include(') 
     && substr($errfile, -19) == 'Varien/Autoload.php' 
    ) { 
     return null; 
    } 
    return call_user_func($handler, $errno, $errstr, $errfile, $errline); 
}); 

如果此代碼是功能setUpBeforeClass內DataTest.php()內,一切正常,但是當我創建bootstrap.php中,並在控制檯執行:

phpunit --bootstrap tests/integration/bootstrap.php tests/integration/ 

我得到了如下回答:

Fatal error: Uncaught exception 'Exception' with message 'Warning: include(PHPUnit\Extensions\Story\TestCase.php): failed to open stream: No such file or directory in C:\wamp\www\magento\lib\Varien\Autoload.php on line 94' in C:\wamp\www\magento\app\code\core\Mage\Core\functions.php on line 245 

Exception: Warning: include(PHPUnit\Extensions\Story\TestCase.php): failed to open stream: No such file or directory in C:\wamp\www\magento\lib\Varien\Autoload.php on line 94 in C:\wamp\www\magento\app\code\core\Mage\Core\functions.php on line 245 

我在斌\ PHP \ php5.5.12我的本地服務器(在Windows中)得到了PHPUnit的,我可以在任何目錄訪問。

所以,我不明白髮生了什麼......因爲我不需要修改magento的核心來禁用警告。

有人能幫助我理解嗎? 謝謝你! :)

回答

1

您的自動加載器試圖加載它不負責的類。

+0

謝謝!確實如此,我所稱的自動加載器是錯誤的。 :) – SundayGirl