I’ve shared a Sublime Text snippet to produce BDD-like test methods for PHPUnit but I couldn’t replicate that in a transition to PphStorm.
The snippet would produce an output, in a PHP
syntax file, like
/**
* @test
* it should do something
*/
public function it_should_do_something()
{
$this->markTestIncomplete();
}
where all that’s needed on the user side is to fill in a whitespace space method description (“do something” in the example).
PHPStorm name for “snippets” is “live templates” and, while working differently from Sublime Text, the underlying mechanics do not seem any less powerful.
After some fiddling I came up with an exact replica of the snippet and since I can’t find any easy way to share the template I’m detailing its brief creation process.
Creation of the live template
In the “Live Templates” section of PhpStorm preferences create a new live template and paste in the following code in the “Template text” section
/**
* @test
* it should $description$
*/
public function it_should_$method$()
{
$this->markTestIncomplete();$END$
}
using the “Edit variables” dialog set the variables like this and that’s done: apply and confirm to enjoy.