4
votes

Does anyone have a verified method to configure PhpStorm 10.x to run unit tests in CakePHP 3.x?

edit: after @ndm's answer I fixed my PhpStorm configuration, adding "phpunit.xml.dist" to PHPUnit > Test Runner: Checked Default configuration file.

now I have different error

/Applications/MAMP/bin/php/php5.6.10/bin/php /Applications/MAMP/htdocs/sites/my_app/vendor/phpunit/phpunit/phpunit --configuration /Applications/MAMP/htdocs/sites/my_app/vendor/phpunit/phpunit/phpunit.xml.dist /Applications/MAMP/htdocs/sites/my_app --teamcity

Testing started at 12:29 ...
PHP Warning: require(/Applications/MAMP/htdocs/sites/my_app/vendor/phpunit/phpunit/tests/../vendor/autoload.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/sites/my_app/vendor/phpunit/phpunit/tests/bootstrap.php on line 3
PHP Fatal error:  require(): Failed opening required '/Applications/MAMP/htdocs/sites/my_app/vendor/phpunit/phpunit/tests/../vendor/autoload.php' (include_path='.:/Applications/MAMP/bin/php/php5.6.10/lib/php') in /Applications/MAMP/htdocs/sites/my_app/vendor/phpunit/phpunit/tests/bootstrap.php on line 3

Process finished with exit code 255

In Run Config, PHPUnit: Test Runner -> Test Scope -> Directory:

/Applications/MAMP/htdocs/sites/my_app/src
1
There's nothing unusual that would need to be done (set the PHP interpreter, set the autoloader and phpunit config file to use). You maybe you want to explain what exactly you are having problems with.ndm
I'm getting this error: PHP Fatal error: Trait 'Aura\Framework\Test\WiringAssertionsTrait' not foundZbigniew Ledwoń
Well, without additional information, like a stacktrace, how you are running the tests, and how you have configured PhpStorm, it's pretty hard to tell what's wrong.ndm
I added some more details.Zbigniew Ledwoń
Why do you point to the apps root directory? This will cause all sub-folders to be inspected for tests, including all dependencies.ndm

1 Answers

6
votes

Without trying to solve your specific error, here's how I have configured PhpStorm.

In Languages & Frameworks > PHP

  • > Interpreter: Pointing to a local PHP executable

  • > PHPUnit > PHPUnit Library: Checked Use custom autoloader, pointing to vendor/autoload.php in the app folder.

  • > PHPUnit > Test Runner: Checked Default configuration file, pointing to phpunit.xml.dist in the app folder.

* All paths should be absolute ones!

And that's all, running tests via the file/folder/code context menus Run ... command works just fine.