PHPStorm / Composer / PHPUnit
I'm trying to setup PHPUnit in a project in PHPStorm.
I've installed PHP 5.6 locally on my Mac.
My PHP application uses composer, so I've included PHPUnit using that;
I've installed PHP 5.6 locally on my Mac.
My PHP application uses composer, so I've included PHPUnit using that;
{
"config": {
"platform": {
"php": "5.6"
}
},
"require": {
"slim/slim": "^3.0",
"slim/extras": "*",
"slim/middleware": "*"
},
"require-dev": {
"phpunit/phpunit": "5.0.*"
}
}
I've setup the PHP interpreter in the project to point to the newly installed PHP instance, and I've added an include path that points to /vendor/phpunit/phpunit/
I've amended the project preferences, Languages and Frameworks > PHP > PHPUnit, selected 'use custom autoloader' and pointed it to the composer autoloader at '/vendor/autoloader.php'.
However I still seem to be getting the following error;
/usr/local/opt/php56/bin/php /private/var/folders/8p/gk_hqwh57gzcvbl87ynjwrtm0000gn/T/ide-phpunit.php --no-configuration MyTest /Users/shaunsheppard/Projects/Sheppard-Digital/APIFramework/Tests/MyTest.php
Testing started at 09:12 ...
Process finished with exit code 1
Cannot find PHPUnit in include path (.:)
As a last resort I've tried settings the PHP Include path in php.ini to '/usr/local/opt/php56/bin' and placing PHPUnit in that folder. I downloaded PHPUnit.phar, placed it into the folder and applied execute permissions 'chmod +x'. I've event tried renaming the file to 'PHPUnit', 'phpunit', 'phpunit.phar', 'PHPUnit.phar' and neither of them make a difference.
What's strange is I have exactly this setup on another machine and it works fine.
请先登录再写评论。
Hello,
Did you try to install PhpUnit via Composer within PhpStorm - right click on the project directory > Composer > Add dependency > phpunit/phpunit? If not then it worth to try this and check the behavior afterwards.
Sorry, I forgot to update this. I did manage to get things working by starting a new project, copying my files across and repeating the steps again.
For some reason I was unable to setup PHPUnit in my existing project, but the new project worked absolutely fine with the same settings.