in phpStorm phpunit php hotfix error ~ read.

Hotfix for problem of running phpunit 4.2.x in latest PHPStorm 7.1

As for today, there's a bug in PHPStorm that doesn't let you run phpunit tests from IDE. Basically it throws :

PHP Warning:  require_once(PHPUnit/Runner/Version.php): 
failed to open stream:
No such file or directory in

/private/var/folders/p1/nz_pbm0j34sd4c9hd35lc55c00013_/T/ide-phpunit.php on line 39
PHP Stack trace:
PHP   1. {main}() 

/private/var/folders/p1/nz_pbm0j34sd4c9hd35lc55c00013_/T/ide-phpunit.php:0
PHP   
2. IDE_PHPUnit_Loader::init()

/private/var/folders/p1/nz_pbm0j34sd4c9hd35lc55c00013_/T/ide-phpunit.php:209
Warning: 
require_once(PHPUnit/Runner/Version.php): 
failed to open stream: No such file or directory in 

/private/var/folders/p1/nz_pbm0j34sd4c9hd35lc55c00013_/T/ide-phpunit.php 
on line 39

PHP   3. IDE_PHPUnit_Loader::detectPHPUnitVersionId()

/private/var/folders/p1/nz_pbm0j34sd4c9hd35lc55c00013_/T/ide-phpunit.php:201

One of the easiest ways is to download 3.7 version of phpunit.phar and in the project settings set this file for phpunit runner. Another solution is more sofisticated, but then you don't have to hardcode phpunit version in your project. Here's what you can do :

A workaround until it is fixed:

  1. go to /plugins/php/lib

  2. make a backup of php.jar

  3. Use whatever tool you have to open the file, usually zip or other compress tools or under ubuntu the file roller.

  4. Go to scripts/phpunit.php

  5. Modify it, searching for the "IDE_PHPUnit_Framework_TestListener" class and adding there the following line:

public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) {}
  1. save the file and update the php.jar

Note 1:
depending on OS and tool you use, you might have to unpack the .jar to modify and compress it back to jar again.

Editing the /tmp/ide-phpunit.php DOES not help, because it get overriden by the phpunit.php file, which I mentioned above.

Note 2:
Also depending on the version, you might find the php.jar elsewhere:

Either here:
Go to your users home directory (windows/linux) and search vor a hidden directory .Webide, while is a number depending on your phpstorm version (e. G. .Webide70)

Or here:
I think earlier versions were named like .IntelliJIdea while is a number depending on your phpstorm version.

And there use the same path (/plugins/php/lib)

One more thing :

According to bug report this issue is fixed in 8th version of PhpStorm and you can try it out as well.
You can download latest EAP version from here

comments powered by Disqus
comments powered by Disqus