PHPUnit and cakePHP (2.x) on local Vagrant machine via PHPStorm 2016.x

I would like to run unit tests on a cakePHP 2.4 instance that is running on a Vagrant machine. The tests work fine via CLI or the web interface testing suite provided by cake. I need to do debugging via Xdebug within PHPStorm, but am having some issues getting it set up.

I have read through this blog article:
https://blog.jetbrains.com/webide/2013/02/running-cakephp2-unit-tests-in-phpstorm/
(note that I have found community contributed updates to the cakeunit4phpstorm.php file.)

The problem arises when configuring PHPStorm. The settings page is completely different than presented in the blog. I am currently using PHPStorm 2016.2.2.

"Use Composer autoloader" is selected, and I have entered the local path to autoload.php (perhaps it needs to be the path on the Vagrant machine?) When trying the absolute path on the Vagrant machine, I am told "Can not find autoloader script at '/var/www/marketplace/Vendor/autoload.php'" And the file finder button opens up on my host machine rather than the guest Vagrant.

I am not sure what to enter in for "Default configuration file" or "Default bootstrap file." At the moment they are both blank.

When I try to run a test inside the IDE, it throws the following:

vagrant:///home/cerekson/Workshop/cleaned/usr/bin/php /home/vagrant/.phpstorm_helpers/phpunit.php --no-configuration UserModelTest /var/www/marketplace/Test/Case/Model/UserTest.php
Testing started at 11:15 AM ...

Process finished with exit code 0
Not running in PhpStorm


Any help with this is most appreciated!

1
5 comments
Avatar
Permanently deleted user

Hello,

Did you configure Vagrant integration? Do you have your project directory mapped to a Vagrant directory?

0
Avatar
Permanently deleted user

Any help on this?

 

I think the error is caused because recent versions of PHPStorm no longer relies on ide-phpunit.php, but calls phpunit scripts directly. But, i'm not able to update the cakeunit4phpstorm.php script

0
Avatar
Permanently deleted user

Does it work in other projects for you? Like running some simple tests with PHPUnit + Vagrant?

0
Avatar
Permanently deleted user

Yes, 

I am able to run tests using the combination Cakephp3+PHPStorm2017.2+Vagrant. CakePHP 3 doesnt need custom runner, it runs nativelly on PHPUnit.

 

The Problem is only with cakephp2, that's why i blame the cakeunit4phpstorm.php script.

0

>  I have entered the local path to autoload.php (perhaps it needs to be the path on the Vagrant machine?)

Yes, it should be path on a Vagrant machine

But the thing is: cakePHP isn't supported yet: https://youtrack.jetbrains.com/issue/WI-8642https://youtrack.jetbrains.com/issue/WI-28466

 

0

Please sign in to leave a comment.