3
votes

Trying to setup remote Codeception Unit Tests in PhpStorm in a Yii2 project.

Using SSH I can log into the server go to the root directory of my Yii2 project and run :

> vendor/bin/codecept run unit

and the tests run.

I'm trying run these remote tests via PhpStorm, I've setup a Remote PHP CLI interpreter and I'm pointing to the Codeception library in my Yii2 project folder:

/var/www/vhosts/mydomain.com/httpdocs/yii2/vendor/bin/codecept

Test Runner points to:

/var/www/vhosts/mydomain.com/httpdocs/yii2/codeception.yml

Trying to run the tests the following command is executed:

> ssh://[email protected]:22/opt/plesk/php/5.6/bin/php /root/.phpstorm_helpers/phpunit.php --no-configuration /var/www/vhosts/mydomain.com/httpdocs/yii2/tests

The process fails at it complains that it cannot find PHPUnit:

Process finished with exit code 1
Cannot find PHPUnit in include path (.:/opt/plesk/php/5.6/share/pear)

How do I get PhpStorm to look for PHPUnit in the yii2/vendor folder? Can I just tell PhpStorm to run a different command instead of this phpstorm_helpers? It seems that the documentation is out of date and the screenshots JetBrains provides are from a different version of PhpStorm, I'm running PhpStorm 2017.3

1
have you installed php-unit, dont use pear-packages they are deprecated - Muhammad Omer Aslam
PHPUnit is installed as part of Yii2 Codeception, I don't know why PHPStorm is looking for a pear package. Again its not an issue when running the tests via SSH. PHPUnit is in /var/www/vhosts/mydomain.com/httpdocs/yii2/vendor/bin/phpunit - keeg
hmm, try this one, go to Languages and Frameworks in the PhpStorm settings. If you click on PHP, on the right you have your include paths, there you should provide the path to the PHPUnit which is vendor/phpunit/phpunit. try it and tell if it works out for you - Muhammad Omer Aslam
it should be vendor/bin/phpunit i just saw the path you specified. - Muhammad Omer Aslam
the include paths seem to be local paths?? - keeg

1 Answers

1
votes

So after a LOT of digging, the issue was with the Run/Debug Configuration. Despite adding Codeception to the Test Frameworks section, clicking the run button still tried to execute a pure PHPUnit test.

To switch to run the test as Codeception, look at the top toolbar above the file tabs: Edit Run/Debug Configuration

There you will be able to define various options:

Configuration Dialog

Now under run you'll have additional options:

Run Menu

Choose the blue Codeception icon to run the test using Codeception instead of PHPUnit