Skip to content

Instantly share code, notes, and snippets.

@claudiofreitas
Last active August 31, 2018 08:17
Show Gist options
  • Save claudiofreitas/4810b1565a6345c6ced1beb3fce4267c to your computer and use it in GitHub Desktop.
Save claudiofreitas/4810b1565a6345c6ced1beb3fce4267c to your computer and use it in GitHub Desktop.
PHPUnit on Docker

PHPUnit on Docker

CLI Interpreter

  1. Open preferences pane (Cmd+,)
  2. Go to Languages & Frameworks > PHP.
  3. On CLI Interpreter, click the ... button.
  4. Click + and From Docker, Vagrant, VM, Remote....
  5. Select Docker, one of the images being used for the project. Then OK.
  6. Click OK again and the CLI Interpreter setting will be complete.
  7. Still on the Languages & Frameworks > PHP, fix the Docker container path.
  8. On Docker container, click ... button, remove the current volume binding and create a new correct one.
  9. In my case it was: /var/www/html
  10. On clicking OK, the Path mappings section will automatically correct itself with those values. OK.

Test Frameworks

  1. On the settings window, go to Language & Frameworks > PHP > Test Frameworks.
  2. Click +, select PHP Unit by remote interpreter, select the CLI Interpreter configured before. OK.
  3. Check that the vendor folder exists. Else, run composer install.
  4. Select Use Composer autoloader and fill the Path to script with the appropriate value. In my case: /var/www/html/vendor/autoload.php (use the full path).
  5. In Test Runner, check Default configuration file and use the full path of the phpunit.xml. My case: /var/www/html/phpunit.xml.dist.
  6. OK to close the Settings window.

Run configurations

  1. Menu Run, item Edit Configurations....
  2. Click +, PHP Unit.
  3. Name it whatever you want. PHPUnit.
  4. Test scope: Defined in the configuration file.
  5. Finish!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment