PHPUnit installation on PhpStorm

Viewed 13951

I am trying to use PHPUnit with PhpSTORM by loading it from autoloader file. But, as you can see in the below screenshot, PHPUnit version: is not installed, i am getting the same even if i choose other two options. i.e. Path to phpunit.phar and Load from include path(PEAR).

enter image description here

here is what i get when i run a test case: enter image description here

PhpUnit classes and code autocompletion is being detected but PhpStorm editor just fine.

2 Answers

If this happens and you see the red I with PHPUnit Version not installed then you probably get the message "Please select PHP Interpreter to load PHPUnit version" when you press the refresh button.

If you have the path to phpunit.phar set and your path the composer autoloader is fine, then it is possible that PHPStorm simply doesn't get what PHP exe file to use to load the PHPUnit.

You can then choose to add a Remote PHP Interpreter but you may also choose to add a local PHP Interpreter (for instance if you have XAMPP or WAMPP or LAMPP installed on your computer).

Press Ctrl+Alt+S and go to -> Languages & Frameworks -> PHP -> CLI Interpreter -> go for the button with the dots (or shift + enter) and there you can add an "Interpreter" by pressing the + button.

I added my own local interpreter xampp\php\php.exe Press apply and okay and go back to Languages & Frameworks -> PHP -> Test Frameworks and go for the refresh button. It should do some magic and then it will say PHPUnit version: 6.5 (or whichever you installed). I had my local (XAMPP) Apache server running.

For anyone running into this in 2020 and also if you have problem with Docker container mapping, Path Mapping stay same if you select your Project root in Docker container option:

Just add double slash at your host path: //, looks like this is bug in PHPStorm.

docker container PHPStorm config

PHPSTorm test framework config

Related