Wednesday, 21 August 2013

Run CakePHP test case in the PHPStorm

If you like me, using PHPStorm as your IDE for writing CakePHP programs, you would very much like running tests in it as well.

Download the file here and put it in your project.
In the menu, go to 'Run'->'Edit Configrations...'->expend 'Defaults' on the left in the window popped up->select 'PHPUnit'->put '-r path_to_cakeunit4phpstorm.php' in the 'interpreter options'->hit 'OK'.
Open one of your test file, put your caret on the name of the test class or above it. Press 'control-shift-r'.
If you haven't set up your PHP interpreter, you will see a window popped up with a 'fix' button on the right bottom. Click on it. Select 'PHP language leavel' and click on '...' after the dropdown for 'interpreter'. Another window will pop up. Click the plus sign and choose your interpreter. Then 'OK', 'OK', 'Run'.

If you want to run individual test method, put the caret on the method name or inside the method and press 'control-shift-r'.