How to configure PhpStorm to use symfony/phpunit-bridge

What I usually do is point my phpunit testing framework on PHPStorm to the secret .phpunit directory which was created by the bridge, like:
enter image description here

The location of the “phar” file is:

bin/.phpunit/phpunit-(major).(minor)/phpunit

or in some cases:

vendor/bin/.phpunit/phpunit-(major).(minor)/phpunit

After this, the specified phpunit executable will be called correctly when exeuting unit-tests, but with a --no-configuration option. This can cause autoloading problems (a lot of “class not found” errors), because the autoloader generated by Composer is not specified anywhere.

To fix this, you should have a phpunit.xml file in your project (this is common practice anyway), in which you specify Composer’s autoloader, something like this:

<phpunit bootstrap="vendor/autoload.php">

This phpunit.xml should then be specified in the “Default configuration file” option and you should be good to go.


Regarding phpstorm using phpunit-bridge:
It’s possible as a custom script, but you won’t have the nice interface and the possibility to run (and debug) specific tests via PHPStorm interface.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)