使用 PHPSTORM 运行测试时 PHPUNIT 错误

标签 php

使用 PhpStorm 运行 phpunit 测试。

收到此错误:

/usr/local/php5/bin/php /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php --configuration /Users/psteinheuser/unity/test/phpunit.xml DatabaseDumperTest /Users/psteinheuser/unity/test/DatabaseDumperTest.inc Testing started at 11:36 AM ...

Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest) in /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php on line 504

Call Stack: 0.0013 340096 1. {main}() /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php:0 PHP Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest) in /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php on line 504

发现以前的帖子说这个问题已经解决了,尽管我似乎有正确的版本,它应该可以工作。

PHPStorm 7.1.3 phpunit 3.7.28 PHP 5.4.24

操作系统是Mac 10.9.2

已经删除并重新安装了 PHPStorm、升级了 php、重新安装了 phpunit、重新启动了 apache、重新启动、抓破了头等等。

从终端手动运行 phpunit 测试,工作正常。

查看 PHpStorm 中的首选项,它似乎正确指向 phpunit。 我认为这是权限或路径问题,但我不知道下一步该看哪里。

感谢任何意见或指示。

最佳答案

在 PHPStorm 中,我能够解决此问题的唯一方法是手动更新存在此错误的 jar 文件的内容。

我们都使用 Mac OSX 10.9,因此这些说明应该适合您。

首先复制现有的 jar 文件:

cp/Applications/PhpStorm.app/plugins/php/lib/php.jar/Applications/PhpStorm.app/plugins/php/lib/php.jar.orig

现在,创建一个临时目录来保存 jar 文件的内容并解压

mkdir ~/jarfiles cd ~/jar 文件 jar xf/Applications/PhpStorm.app/plugins/php/lib/php.jar

解压后,您需要编辑 phpunit.php 文件以添加缺少的方法 stub

vi 脚本/phpunit.php

我的文件中第 310 行左右是一个类“IDE_PHPUnit_Framework_TestListener”。插入以下方法 stub :

公共(public)函数addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time){}

现在只需重新打包您的 jar 并将其替换到您的 PhpStorm 中即可:

jar cf0 php.jar ./* mv php.jar/Applications/PhpStorm.app/plugins/php/lib/php.jar

这为我解决了这个问题。希望它也能为你解决这个问题。祝你好运!

关于使用 PHPSTORM 运行测试时 PHPUNIT 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22717525/

相关文章:

javascript - Ionic + Angular - 如何在 POST 请求后避免 "404 Not Found (from cache)"?

javascript - 当 Bootstrap 验证成功时,如何使用 $.post 提交表单而不进行页面重定向?

php - 无法在 bindparam PDO 中使用 ORDER BY 和 ASC/DESC

php - 从数据库填充的菜单

Javascript 等价于 PHP Explode()

javascript - 从 .SRT 文件中添加或减去秒数

php - 如何批量更新 Google 表格附加数字而不是字符串/撇号

javascript - 为什么我无法通过 Ajax 获取 WP 自定义字段值或发布 ID?

PHP session_set_cookie_params() 问题

php - Codeigniter:下拉验证 set_rules