Phpunit woes local development

phpunit has stopped working for me, locally. When I first set up bedrock/trellis for pb it worked no problem. It’s now telling me the phpunit command on remote server is ‘empty’. My config is set up the same/similar as is outlined here:

I’m running out of troubleshooting steam - anyone have similar issues, or know what’s changed? I can’t say that I’m aware of anything changing on my end.


@dac.chartrand uses PHPStorm and might have ideas—sorry I can’t be more help, @brad.

This is my setup for PhpStorm 2018.1.6

PHPUnit Library -> Path To Script: is where the autoloader lives in vagrant, not on my computer.

It was important to map the remote path to the local path.

In the past things stopped working for me because I went from http to https (xdebug) so I had to add a second server for port 443, and my paths used to be called now it’s pressbooks.test.

Hope this helps?

PS: I often just run the tests from inside vagrant at the command prompt.

For Pressbooks:

vagrant ssh
cd /srv/www/pressbooks.test/current/
composer test

Here’s how I test other plugins, same first three steps then:

PB_PLUGIN=pressbooks-lti-provider composer test

Where pressbooks-lti-provider is your plugin’s dir slug.

Here’s a peek inside /srv/www/pressbooks.test/current/compose.json (I make modifications in there for dev work, private repos,don’t commit everything back because it’s not always generic)

  "require-dev": {
    "phpunit/phpunit": "6.5.8",
    "pressbooks/coding-standards": "dev-master"

  "scripts": {
    "test": [
      "PB_PLUGIN=${PB_PLUGIN:-pressbooks}; vendor/bin/phpunit --configuration web/app/plugins/$PB_PLUGIN/phpunit.xml",
    "standards": [
      "PB_PLUGIN=${PB_PLUGIN:-pressbooks}; vendor/bin/phpcs --standard=web/app/plugins/$PB_PLUGIN/phpcs.ruleset.xml web/app/plugins/$PB_PLUGIN/*.php web/app/plugins/$PB_PLUGIN/inc/ web/app/plugins/$PB_PLUGIN/bin/"

Allows me to consolidate into a single /vendor dir.

Bonus: If you are not generating Code Coverage then you should turn off XDEBUG at the CLI. The tests will run much faster.

vagrant ssh
cd /etc/php/7.2/cli/conf.d

Remove the xdebug symlink, keep it in /etc/php/7.2/fpm/conf.d/ for the browser.

@dac.chartrand thank you very much for this documentation. Fortunately phpunit config is solid on my non-bedrock development instance of PB so was able to use that today. When I have time to look into it, I’ll report back with what the problem was. Thanks again, this is an amazing amount of detail. I appreciate it.

1 Like