Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit installation on PhpStorm

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.

like image 378
Fshamri Avatar asked Aug 05 '17 06:08

Fshamri


People also ask

Can not find PHPUnit library to install use PHP composer Phar install?

First go to Settings -> Languages and Frameworks -> PHP and Add a remote interpreter, then go to Settings -> Languages and Frameworks -> PHP -> PHPUnit click the + on top and click by Remote Interpreter . If you're using Composer autoloader, then enter your full Vagrant path to your autoloader file.

How do I know if PHPUnit is installed on Windows?

To verify PHPUnit has been installed type phpunit --version in command prompt. You should get something like PHPUnit x.y.z by Sebastian Bergmann and contributors.

What is PHPUnit used for?

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit architecture for unit testing frameworks that originated with SUnit and became popular with JUnit. PHPUnit was created by Sebastian Bergmann and its development is hosted on GitHub.


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.

like image 108
Isolde Avatar answered Oct 14 '22 01:10

Isolde


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

like image 2
KorbenDallas Avatar answered Oct 13 '22 23:10

KorbenDallas