IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

Generate PHP tests

Last modified: 10 August 2022

You can have the test class stubs generated automatically based on the PHP classes that are subject for testing. IntelliJ IDEA provides this ability for the PHPUnit, Codeception, and PHPSpec test frameworks. If you are using Behat framework, you have to create tests manually.

A Test class is a PHP class with its name derived from the production class name. For example, if the class to test is MyClass.php, IntelliJ IDEA will automatically compose the name for the corresponding PHPUnit test class as <MyClass>Test.php.

IntelliJ IDEA can generate tests for the classes that are defined in separate files as well as for the classes that are defined within a single PHP file. In the latter case, for each generated test class IntelliJ IDEA will create a separate file.

After creating the test, you can quickly navigate between the test and the test subject.