phpsymfonyphpunitphpstormphing

Testing Configuration fails - PHPUnit, Symfony, PHPStorm, Phing


I have a backend system based on Symfony 3.x, and I work on PHPStorm 2017.x. My Server is a regular XAMPP 5.6.8 stack with Apache and MySQL only, and I applied the latest compatible phpunit.phar (5.7.20) to the "php"-folder in the XAMPP-directory. I am supposed to run PHPUnit tests with a Phing buildfile, however the internal PHPStorm terminal displays an error:

Fatal error: Class 'PHPUnit\Framework\TestCase' not found in O:\%PROJECT_DIR%\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php on line 25

In my current project settings, I pointed to the phpunit.phar within my XAMPP-directory, but somehow it still tries to find the phpunit within the Symfony vendor directory. Where exactly is the source of the error and how can I correct it? Is it Phing-based?

EDIT: Adding the error call stack:

Call Stack:
0.0003     121616   1. {main}() O:\xampp_5_6_8\php\phpunit:0
0.0064     357360   2. PHPUnit_TextUI_Command::main() O:\xampp_5_6_8\php\phpunit:46
0.0064     360760   3. PHPUnit_TextUI_Command->run() O:\xampp_5_6_8\php\pear\PHPUnit\TextUI\Command.php:129
0.0064     361968   4. PHPUnit_TextUI_Command->handleArguments() O:\xampp_5_6_8\php\pear\PHPUnit\TextUI\Command.php:138
0.0212     833056   5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() O:\xampp_5_6_8\php\pear\PHPUnit\TextUI\Command.php:657
0.0212     833720   6. PHPUnit_Util_Configuration->getTestSuite() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Configuration.php:789
0.0609     976960   7. PHPUnit_Framework_TestSuite->addTestFiles() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Configuration.php:873
0.0609     978088   8. PHPUnit_Framework_TestSuite->addTestFile() O:\xampp_5_6_8\php\pear\PHPUnit\Framework\TestSuite.php:416
0.0623    1033248   9. PHPUnit_Util_Fileloader::checkAndLoad() O:\xampp_5_6_8\php\pear\PHPUnit\Framework\TestSuite.php:355
0.0634    1033416  10. PHPUnit_Util_Fileloader::load() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:76
0.0642    1054496  11. include_once('O:\%PROJECT_DIR%\src\App\Bundle\Tests\Controller\ControllerTest.php') O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:92
0.0643    1054728  12. spl_autoload_call() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:11
0.0643    1054784  13. Composer\Autoload\ClassLoader->loadClass() O:\xampp_5_6_8\php\pear\PHPUnit\Util\Fileloader.php:0
0.0647    1054960  14. Composer\Autoload\includeFile() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:301
0.0653    1059352  15. include('O:\%PROJECT_DIR%\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\WebTestCase.php') O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:414
0.0653    1059592  16. spl_autoload_call() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:22
0.0653    1059656  17. Composer\Autoload\ClassLoader->loadClass() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:0
0.0657    1059832  18. Composer\Autoload\includeFile() O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:301
0.0664    1091728  19. include('O:\%PROJECT_DIR%\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\KernelTestCase.php') O:\%PROJECT_DIR%\vendor\composer\ClassLoader.php:414

Solution

  • PHPUnit\Framework\TestCase is a reference to PhpUnit 6 test version while you're using phpunit.phar (5.7.20). Try to replace it with the latest 6.* version.