Running CakePHP Unit Tests with TextMate

As most people know TextMate is a pretty amazing text editor, probably one of the best for MacOS. What you may not know is that CakePHP has its own textmate bundle. this bundle is maintained by JoÃ«l Perras who is also a recent addition to the CakePHP core team. JoÃ«l & Andy Dawson have been working on another project called CakeMate CakeMate is described as

A plugin used to extend the functionality of the CakePHP TextMate bundle, which can be found on “The Chaw”: http://thechaw.com/cakephp_tmbundle This plugin is designed to work in conjunction with the Textmate bundle, and will not work as a standalone.

Sounds pretty cool eh? Well it is. If you write and run unit tests all day CakeMate might help reduce all the cmd+tab, cmd+r you are doing. CakeMate is still a work in progress, but the testing shell works. I spent a few hours on the weekend updating the output to make it prettier and easier to read. You can find those in my fork of CakeMate and hopefully in the main fork as well.

Using CakeMate to run tests

So in order to run unit tests using CakeMate you need to download and place it in your app/plugins directory, or otherwise link it up Once that is done, you need to create a command in TextMate so you can run the CakeMate tester shell. Mine looks like

You’ll want to set the input as “None”, and the output as “Show as Html” I’ve bound this to command to cmd+ctrl+r. Once you’ve added the command, anytime you have a test case as the active document, you can hit your command and run the test. You should get a popup that looks a little like this

No more having to leave textmate to run unit tests which is really nice.

Comments

For general information, as soon as the CakeMate plugin stabilizes a bit, there will be an update to the CakePHP.tmbundle (the CakePHP Textmate bundle) which will include the above Textmate Command that Mark has described, as well as a few others. This will provide a more cohesive link between the plugin and the bundle, and will also facilitate the writing of Textmate commands/extensions/etc. using the functionality that CakePHP shells provide.

Watch the CakeMate repository to follow the development (or – even better – fork it & help out!).

Recent Artwork

Links

Mark is a designer and web-developer, working with standards compliant HTML and CSS. He has been building websites since 2000. Currently he is employed at Freshbooks as a developer, and actively contributes to open source projects specifically CakePHP. He uses this site as a place to share what he has learned and made.