I
I
Ivan Panteleev2014-03-10 01:37:43
PHP
Ivan Panteleev, 2014-03-10 01:37:43

HomeBrew + PHPUnit + PhpStorm, how to make it work?

I have Mac OS X with HomeBrew installed. It has already happened that it seems to me that it is easier to install the necessary software through brew:

brew install phpunit
==> Downloading https://phar.phpunit.de/phpunit-4.0.1.phar
Already downloaded: /Library/Caches/Homebrew/phpunit-4.0.1.phar
/usr/local/Cellar/phpunit/4.0.1: 3 files, 3.1M, built in 2 seconds

The installation went well and the test file from the console worked fine:
phpunit ~/Sites/localhost/PHPUnit/test.php
PHPUnit 4.0.1 by Sebastian Bergmann.

..

Time: 35 ms, Memory: 3.25Mb

OK (2 tests, 2 assertions)

But when trying to run the same file from PhpStorm, we get:
PHP Warning:  require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /private/var/folders/kg/gxwxzvp15lq254j52xbr4tnr0000gn/T/ide-phpunit.php on line 39
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/usr/local/Cellar/php55/5.5.10/lib/php:/usr/local/bin') in /private/var/folders/kg/gxwxzvp15lq254j52xbr4tnr0000gn/T/ide-phpunit.php on line 39

It is worth noting that in the PhpStorm settings, in the PHP - PHPUnit section, the item "Load from include path" is specified, if you change it to "Path to pharunit.phar" and specify the path to the file:
/usr/local/Cellar/phpunit/4.0.1/libexec/phpunit-4.0.1.phar

then we will run into this bug , it has already been fixed, but, firstly, this approach is inconvenient because the path here depends on the version and there will be problems after updating PHPUnit, and secondly, the version with the fix has not yet been released.
How to make PhpStorm friends with PHPUnit?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2014-11-21
@Nc_Soft

PhpStorm is not compatible with phpUnit > 4
Just comment out all require_once in CTestCase.php to make it work

require_once('PHPUnit/Runner/Version.php');
require_once('PHPUnit/Util/Filesystem.php'); // workaround for PHPUnit <= 3.6.11
require_once('PHPUnit/Autoload.php');

Or make your own class where these connections do not exist
abstract class TestCase extends PHPUnit_Framework_TestCase
{
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question