/Live Template For PHPUnit Tests
Forked from drfraker/Live Template For PHPUnit Tests
Created Jun 25, 2019
Live Template For PHPUnit Tests
// 1. In PhpStorm go to: Preferences > Editor > Live Templates. | |
// 2. Click on the + button on the top right to create a new template. | |
// 3. Enter "@test" (no quotes) in the Abbreviation field, and give the template a name. (mine is named test case) | |
// 4. Copy and paste the code below into the "Template text:" section in PhpStorm | |
/** @test */ | |
$NAME$ | |
public function $SNAKENAME$() | |
{ | |
$END$ | |
} | |
// 6. Click the edit variables button on the right of the code window | |
// a. Leave the NAME variable blank. | |
// b. Choose the expression snakeCase() and enter the NAME variable as the string to snake case. | |
// c. The final result should be snakeCase(NAME) | |
// 7. Click the define button at the bottom of the screen and select the box labeled PHP to allow this template to be used in php files. | |
// 8. Select the box next to "Reformat according to style to insert the template according to your PHP style settings. | |
// That's it, now it should work! | |
// type @test and press tab to insert the template in a phpunit test file, | |
// type the name of the test and PhpStorm will automatically convert it to snake case. Once it's named, delete the original text with cmd + delete | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment