PHPUnit - Generate Template

Is there a way to modify this template? It is way off from what I plan to use and the formatting is not our standard.

Comment actions Permalink

Hi Keith,

The answer is "No" and "Yes" at the same time.

No -- because such test class is not generated by PhpStorm -- it generated by PHPUnit itself. Lets say I have class cfGravatar inside Gravatar.php file. The appropriate command (must be run in the folder where Gravatar.php is located) will be:

phpunit --skeleton-test cfGravatar Gravatar.php

The result will be newly created cfGravatarTest.php file.

Yes -- template can be changed, but you have to edit PHPUnit files. Have a look at

Comment actions Permalink

Keith, if you still interested: no need to edit the original template file (which will be overwritten when you update you PHPUnit to a newer version) -- just make duplicate of that TestClass.tpl.dist file (place in the same folder next to original) and name it TestClass.tpl -- such names (without .dist extension) have higher priority when template is loaded. The same goes to individual methods templates (other files in the same folder).

Unfortunately folder/file names are hardcoded and there is no special method/property that can be used to pass custom folder/filenames (so they can be used intead of bundled).


Please sign in to leave a comment.