Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Redirect

...

locationhttps://www.jetbrains.com/help/phpstorm/enabling-php-unit-support.html
delay2

Include Page
Social Buttons PhpStorm
Social Buttons PhpStorm


Image AddedSince version 3.7, PHPUnit allows us to install the test runner and optional dependencies using Composer. With PhpStorm 6, this workflow is now supported from the IDE. Using both the bundled Composer support and PhpStorm's unit testing support, we can install PHPUnit via Composer without any hassle. Let's find out how. Image Removed

...


Let's start off with a blank project. We can

...

use the

...

Tools | Composer | Init Composer...

...

 menu command to enable Composer support for our project. If you don't have

...

composer.phar anywhere on your system, the Click here to download from getcomposer.org helper will download the latest composer.phar from the official website.
Once initialized, we can use the

...

PhpStorm

...

Composer support to add dependencies. We can

...

use the

...

Composer | Manage Dependencies...

...

command to download PHPUnit into our project. That's right: PhpStorm

...

comes with a nice UI for searching packages from the Packagist website.

...


Image Added

After

...

PHPUnit and all dependencies are installed successfully, our project's structure is now the following: the vendor folder containing all dependencies brought in using Composer, including PHPUnit.

...


Image Added
Just like with PHPUnit installed using PEAR or as a PHAR file, we need to configure

...

the location of PHPUnit

...

in PhpStorm. In File | Settings (PhpStorm | Preferences on Mac) | Languages & Frameworks | PHP | Test Frameworks, select the PHPUnit Local page. We can now select the

...

Use Composer autoloader option and specify the path to

...

the autoload.php file generated by Composer. Optionally we can specify a default PHPUnit configuration file or a PHPUnit bootstrap file to be used when running tests.

...


Image Added

Our run configuration will look pretty simple: specify the directory containing tests (or a specific class/method or rely on the PHPUnit configuration file to find tests to run).

...

Image Added

...

http://youtrack.jetbrains.com/dashboard#newissue=yes\]here

, and leave questions in the comments below or in our[

...

http://devnet.jetbrains.com/community/wi?view=discussions\]forums\

!
Develop with pleasure!
-- JetBrains Web IDE Team

We can now invoke this run configuration and have our unit tests running using the PHPUnit version installed through Composer.

...


Image Added

Include Page
Social Buttons PhpStorm
Social Buttons PhpStorm