Search code examples
phpunitphpstorm

Linking PHPUnit with PhpStorm


PHPUnit: 4.8.31 PhpStorm: 2016.1

I'm having issues running PHPUnit from within PhpStorm. From a CMD window, running the test works fine, but the PhpStorm output is this:

"C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\php.exe" C:/Users/username/AppData/Local/Temp/ide-phpunit.php --no-configuration "C:\tests"
Testing started at 5:30 PM ...

Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\ext\php_curl.dll' - The specified procedure could not be found.
 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\ext\php_curl.dll' - The specified procedure could not be found.

Fatal error: Class 'PHPUnit_TextUI_ResultPrinter' not found in C:\Users\username\AppData\Local\Temp\ide-phpunit.php on line 253 in Unknown on line 0

PHP Fatal error:  Class 'PHPUnit_TextUI_ResultPrinter' not found in C:\Users\username\AppData\Local\Temp\ide-phpunit.php on line 253

Process finished with exit code 255

I've included the folder with my phpunit.phar library in PhpStorm:

enter image description here

PhpStorm knows about the include paths, autocomplete works.

The run config looks like this:

enter image description here

The PHP version/install I'm using is the same one.

  • Windows: enter image description here

  • PhpStorm: enter image description here

Any ideas?


Solution

  • I tried running a script that uses curl from a CMD window and saw that the curl library wasn't loaded.

    I did phpinfo(); and saw that the CMD window was using a different PHP installation (I had installed a new EasyPHP version).

    I made the windows sys variable PATH point at my old one, then it started throwing some errors about not loading some libraries (php_curl.dll, libssh2.dll), so I moved them from the new install folder to the old one and to Windows\SysWOW64. Miraculously, the PhpStorm run config was also fixed, which leads me to believe it doesn't use the interpreter I set in its options, but rather the one from PATH..

    The PhpStorm output is now:

    "C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-binaries\php\php704vc14x86x161109103716\php.exe" C:/Users/username/AppData/Local/Temp/ide-phpunit.php --no-configuration "C:\tests"
    Testing started at 9:22 AM ...
    
    Warning: The use statement with non-compound name 'PHPUnit_Framework_TestCase' has no effect in C:\DummyTest.php on line 3
    PHPUnit 4.8.31 by Sebastian Bergmann and contributors.
    
    PHP Warning:  The use statement with non-compound name 'PHPUnit_Framework_TestCase' has no effect in C:\DummyTest.php on line 3
    
    No tests found in class "TestDummy".
    
    
    Time: 372 ms, Memory: 10.00MB
    
    
    FAILURES!
    Tests: 1, Assertions: 0, Failures: 1.
    
    Process finished with exit code 1