警告在 Magento 项目中包含 TestCase phpunit
Warning include TestCase phpunit in Magento project
我在 magento 的项目中使用 phpunit 进行测试。
问题是我在 magento 中得到了这个目录:
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
我在 bin\php\php5.5.12(在 Windows)的本地服务器中安装了 phpunit,我可以在任何目录中访问。
所以,我不明白发生了什么...因为我不需要修改 magento 的核心来禁用警告。
有人能帮我理解一下吗?
谢谢大家!!
:)
您的自动加载器正在尝试加载 类 它不负责。
我在 magento 的项目中使用 phpunit 进行测试。 问题是我在 magento 中得到了这个目录:
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
我在 bin\php\php5.5.12(在 Windows)的本地服务器中安装了 phpunit,我可以在任何目录中访问。
所以,我不明白发生了什么...因为我不需要修改 magento 的核心来禁用警告。
有人能帮我理解一下吗? 谢谢大家!! :)
您的自动加载器正在尝试加载 类 它不负责。