Phpunit error in PhpStorm
Silly mistake on my part... simply forgot to add phpunit as a dependency in the project. For anyone else that gets this error, to composer.json add:
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
And then run:
composer update
That solved the problem.
I had the same issue with Ubuntu 16.10, phpStorm 2017.2 and Laravel 5.5
Fixed it by uninstalling phpunit from my Ubuntu-system with
sudo apt-get remove phpunit
sudo apt-get install --autoremove
or for mac:
brew uninstall phpunit
brew install phpunit
My PhpStorm configuration (File -> Settings -> Languages & Frameworks -> PHP -> Test Frameworks):
Works great, now!
In my case the problem was caused by following set of reasons:
- I installed phpunit using composer with
composer require phpunit/phpunit
command. I did not pay attention that by default it used php7 and it installed phpunit6 which has class names with namespaces (PHPUnit\TextUI\ResultPrinter
). - IDE runs old version of phpunit which expects class names without namespaces (
PHPUnit_TextUI_ResultPrinter
)
I decided to reinstall phpunit
running same composer command as above, but under php 5.6
(because it was important to be compatible with php5.6) and it installed phpunit 5.7
.
But it is possible to go with newer version of phpunit and php: Settings > PHP > PHPUnit :: "Use composer autoloader"
(set path to phpunit executable inside vendors (it was vendors/bin/phpunit
in my case))