PHP警告包括PHPUnit_Extensions_Story_TestCase.php无法打开流

前端之家收集整理的这篇文章主要介绍了PHP警告包括PHPUnit_Extensions_Story_TestCase.php无法打开流前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用 PHP Yii框架并运行功能测试.
我已经安装了PHPUnit_Story
pear install PHPunit/PHPUnit_Story

而扩展就在那里

/usr/share/PHP/PHPUnit/Extensions/Story

但我得到错误

PHP Warning:  include(PHPUnit_Extensions_Story_TestCase.PHP): Failed to open stream: No such file or directory in /var/www/yii/framework/YiiBase.PHP on line 427
PHP Stack trace:
PHP   1. {main}() /usr/bin/PHPunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/PHPunit:581
PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/bin/PHPunit/PHPunit/TextUI/Command.PHP:132
PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/bin/PHPunit/PHPunit/TextUI/Command.PHP:179
PHP   5. PHPUnit_TextUI_ResultPrinter->printResult() phar:///usr/bin/PHPunit/PHPunit/TextUI/TestRunner.PHP:425
PHP   6. PHPUnit_TextUI_ResultPrinter->printFailures() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:177
PHP   7. PHPUnit_TextUI_ResultPrinter->printDefects() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:322
PHP   8. PHPUnit_TextUI_ResultPrinter->printDefect() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:243
PHP   9. PHPUnit_TextUI_ResultPrinter->printDefectTrace() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:254
PHP  10. PHPUnit_Util_Filter::getFilteredStacktrace() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:290
PHP  11. PHPUnit_Util_Blacklist->isBlacklisted() phar:///usr/bin/PHPunit/PHPunit/Util/Filter.PHP:105
PHP  12. PHPUnit_Util_Blacklist->initialize() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:74
PHP  13. class_exists() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:110
PHP  14. spl_autoload_call() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:110
PHP  15. YiiBase::autoload() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:0
PHP Warning:  include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.PHP' for inclusion (include_path='.:/var/www/yii-example/protected/components:/var/www/yii-example/protected/models:/usr/share/PHP:/usr/share/pear') in /var/www/yii/framework/YiiBase.PHP on line 427
PHP Stack trace:
PHP   1. {main}() /usr/bin/PHPunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/PHPunit:581
PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/bin/PHPunit/PHPunit/TextUI/Command.PHP:132
PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/bin/PHPunit/PHPunit/TextUI/Command.PHP:179
PHP   5. PHPUnit_TextUI_ResultPrinter->printResult() phar:///usr/bin/PHPunit/PHPunit/TextUI/TestRunner.PHP:425
PHP   6. PHPUnit_TextUI_ResultPrinter->printFailures() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:177
PHP   7. PHPUnit_TextUI_ResultPrinter->printDefects() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:322
PHP   8. PHPUnit_TextUI_ResultPrinter->printDefect() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:243
PHP   9. PHPUnit_TextUI_ResultPrinter->printDefectTrace() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:254
PHP  10. PHPUnit_Util_Filter::getFilteredStacktrace() phar:///usr/bin/PHPunit/PHPunit/TextUI/ResultPrinter.PHP:290
PHP  11. PHPUnit_Util_Blacklist->isBlacklisted() phar:///usr/bin/PHPunit/PHPunit/Util/Filter.PHP:105
PHP  12. PHPUnit_Util_Blacklist->initialize() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:74
PHP  13. class_exists() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:110
PHP  14. spl_autoload_call() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:110
PHP  15. YiiBase::autoload() phar:///usr/bin/PHPunit/PHPunit/Util/Blacklist.PHP:0
看起来PHPUnit和Yii自动加载器之间存在一些问题. PHPUnit正在切换到使用单个phar存档,因此Yii尝试包含的文件不再存在.

现在推荐的安装PHPUnit和依赖项的方法是使用Composer.我花了几天时间使用PEAR与它的所有怪癖作斗争,但是这个作曲家和Yii的教程让我在几分钟内再次运行单元测试:

http://blog.mediasuite.co.nz/tip-how-to-set-up-phpunit-for-yii-using-composer/

基本步骤:

在项目根目录中创建composer.json文件

{
    "require-dev": {
        "PHPunit/PHPunit": "3.7.*","PHPunit/PHPunit-selenium": ">=1.2","PHPunit/dbunit": ">=1.2","PHPunit/PHPunit-story": "*","PHPunit/PHP-invoker": "*"
    },"autoload": {
        "psr-0": {"": "src"}
    },"config": {
        "bin-dir": "bin/"
    }
}

使用以下命令将composer安装到项目中:

curl -sS https://getcomposer.org/installer | PHP

确保作曲家是可执行的:

chmod +x composer.phar

让composer安装依赖项:

./composer.phar install --dev

检查您是否安装了项目特定的PHPunit版本:

./bin/PHPunit --version

现在在protected / tests中,您可以使用以下命令运行单元测试:

../../bin/PHPunit unit

和你的硒测试

../../bin/PHPunit functional

如果您正在使用版本控制,最好提交composer.json和composer.lock文件,但忽略/ vendor文件夹的内容

原文链接:https://www.f2er.com/php/136950.html

猜你在找的PHP相关文章