Skip to content

Instantly share code, notes, and snippets.

@tonythere
Last active August 29, 2015 14:23
Show Gist options
  • Save tonythere/f5bcb162aa1f6914932d to your computer and use it in GitHub Desktop.
Save tonythere/f5bcb162aa1f6914932d to your computer and use it in GitHub Desktop.
  • Go to File -> Settings -> PHP -> PHPUNIT.
  • Select Use custom loader and then enter the autoload.php file from your projects vendor directory. This autoloader will autoload all the dependencies managed by Composer (including PHPUnit).
  • Specify the default configuration file (this is usually phpunit.xml.dist from your project's app directory). image 1

@aderuwe's answer works but that config isn't scoped per project, it's for all projects. Since PHPStorm 6 (actually even EAP version PS-126.260) you can do the following:

Go to File -> Settings -> PHP -> PHPUNIT. Select Use custom loader and then enter the autoload.php file from your projects vendor directory. This autoloader will autoload all the dependencies managed by Composer (including PHPUnit). Specify the default configuration file (this is usually phpunit.xml.dist from your project's app directory). PHP -> PHPUNIT

That needs to be repeated per project, but the following needs to be done once.

You need to configure you defaults in PHPStorm correctly.

  • Go to Run -> Edit Configurations... or just click the dropdown menu on the toolbar and select Edit Configurations....
  • Go to Defaults -> PHPUnit
  • Under Test Scope, select Defined in configuration file
  • Make sure the Interpreter options textfield is empty
  • Go to PHPUnit (above Defaults) and delete any entry under it (so that next time you a test on a particular file, etc. it'll set up a new one but using the new default). image 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment