简体   繁体   English

使用 PHPSTORM 运行测试时出现 PHPUNIT 错误

[英]PHPUNIT error when running tests with PHPSTORM

Running phpunit tests using PhpStorm.使用 PhpStorm 运行 phpunit 测试。

Receiving this error:收到此错误:

/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 ... /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 测试于上午 11:36 开始......

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致命错误:IDE_PHPUnit_Framework_TestListener 类包含 1 个抽象方法,因此必须在 line-phpunit.php 上的 /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php 中声明为抽象方法或实现其余方法 (PHPUnit_Framework_TestListener::addRiskyTest)。

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调用堆栈:0.0013 340096 1. {main}() /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php:0 PHP 致命错误:类 IDE_PHPUnit_Framework_TestListener 因此必须包含抽象抽象504 行 /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php 中的其余方法(PHPUnit_Framework_TestListener::addRiskyTest)

Have found previous posts which have said this is fixed, though I seem to have the correct versions where it should work.发现以前的帖子说这是固定的,但我似乎有它应该工作的正确版本。

PHPStorm 7.1.3 phpunit 3.7.28 php 5.4.24 PHPStorm 7.1.3 phpunit 3.7.28 php 5.4.24

The OS is Mac 10.9.2操作系统为 Mac 10.9.2

Have removed and re-installed PHPStorm, upgraded php, re-installed phpunit, restarted apache, rebooted, scratched my head, etc.删除并重新安装了PHPStorm,升级了php,重新安装了phpunit,重新启动了apache,重新启动了,抓了我的头等。

Running the phpunit tests manually from the terminal, works fine.从终端手动运行 phpunit 测试,工作正常。

Looking at Preferences within PHpStorm, it seems to be pointing to phpunit correctly.查看 PHpStorm 中的首选项,它似乎正确地指向了 phpunit。 I'm thinking it's a permission or path issue, but I don't know where to look next.我认为这是权限或路径问题,但我不知道下一步该往哪里看。

Appreciate any input or direction.感谢任何输入或方向。

In PHPStorm, the only way I was able to solve this was by manually updating the contents of the jar file where this error exists.在 PHPStorm 中,我能够解决此问题的唯一方法是手动更新存在此错误的 jar 文件的内容。

We're both on Mac OSX 10.9, so these instructions should work for you.我们都在 Mac OSX 10.9 上,所以这些说明应该对你有用。

Begin by making a copy of the existing jar file:首先复制现有的 jar 文件:

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

Now, create a temporary directory to hold your jar file's contents and extract现在,创建一个临时目录来保存 jar 文件的内容并解压缩

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

Once extracted, you'll need to edit the phpunit.php file to add the missing method stub解压后,您需要编辑 phpunit.php 文件以添加缺少的方法存根

vi scripts/phpunit.php

Around line 310 in my file is a class 'IDE_PHPUnit_Framework_TestListener'.我的文件中的第 310 行是一个类“IDE_PHPUnit_Framework_TestListener”。 Insert the following method stub:插入以下方法存根:

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

Now just re-pack your jar and replace it into your PhpStorm:现在只需重新打包您的 jar 并将其替换到您的 PhpStorm 中:

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

That fixed it for me.那为我修好了。 Hope it fixes it for you too.希望它也为您解决。 Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM