简体   繁体   中英

PHPUNIT error when running tests with PHPSTORM

Running phpunit tests using PhpStorm.

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 ...

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

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

The OS is Mac 10.9.2

Have removed and re-installed PHPStorm, upgraded php, re-installed phpunit, restarted apache, rebooted, scratched my head, etc.

Running the phpunit tests manually from the terminal, works fine.

Looking at Preferences within PHpStorm, it seems to be pointing to phpunit correctly. 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.

We're both on Mac OSX 10.9, so these instructions should work for you.

Begin by making a copy of the existing jar file:

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

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

vi scripts/phpunit.php

Around line 310 in my file is a class 'IDE_PHPUnit_Framework_TestListener'. Insert the following method stub:

public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time){}

Now just re-pack your jar and replace it into your 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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