IntelliJ IDEA 2018.2 Help

Create New PHP Test Dialog

File | New | PHP Test | Test
Project tool window | Context menu of a class | New | PHP Test | Test

Use this dialog to configure generation of PHP test class stubs for the supported test frameworks.

ItemDescription
Test file template In this list, select the test file template based on which the test class will be generated. IntelliJ IDEA provides the built-in templates for the following test frameworks: PHPUnit, Codeception, and PHPSpec.
Class To Test (optional) In this area, specify the production class to generate a test class for. Type the fully qualified name of the class in the Fully qualified name text box. The specified name will be used to propose the Test Class Name. To use completion, press Ctrl+Space and choose the relevant production class from the pop-up list.
Test Class
  • Name: in this text box, specify the name of the test class to generate. IntelliJ IDEA automatically composes the name from the production class name according to the naming conventions of the chosen test framework, for example, <production class>Test.php for a PHPUnit test class.
  • Namespace: in this text box, specify the namespace the test class will belong to. IntelliJ IDEA completes the namespace automatically based on the value of the Directory text box. When the Directory text box is changed, the value of the Namespace text box is changed accordingly. To use completion, press Ctrl+Space and choose the relevant namespace from the pop-up list.
  • File Name: in this text box, specify the name of the file that will be created for the test class definition. By default, the name is the same as the test class name. However, if several production classes are defined in one single file, for each generated test class IntelliJ IDEA will create a separate file.
  • Directory: in this text box, specify the directory where the file with the test class will be stored. By default, it is the directory where the production class is stored. To specify a different directory, click Browse and choose the relevant directory in the dialog box that opens. To use completion, press Ctrl+Space and choose the relevant directory from the pop-up list.
Generate test methods for

In the table, select the checkboxes next to the production class methods you want to generate test method stubs for. To include inherited methods from parent classes, select the Show inherited methods checkbox. IntelliJ IDEA will automatically compose the test methods' names as test<production method>.

You can customize the code templates used for generating test method stubs on the Code tab of the File and Code Templates settings page.

Last modified: 18 June 2018

See Also