I have been looking for a tutorial to help me integrate PHPUnit with CakePHP. Looking to use Selenium tests too so prefer PHPUnit.
I have been trying to follow the tutorial on http://cakebaker.42dh.com/2006/03/22/selenium/ but cant seem to get it work. Any good tutorials out there?
Thanks!
Unfortunately CakePHP isn't designed to work together with PHPUnit. CakePHP has switched to using SimpleTest and you'll have one of two choices, refactor your tests to work with SimpleTest or modify the core to use PHPUnit.
However it should be stated that Mark Story has stated that CakePHP 2.0 will use PHPUnit for it's testing framework, so if you can aford to wait till then that may wind up being the best option.
CakePHP 1.3 Book on Testing
It's relatively easy. I use cake 1.3 from composer installation. This is how my composer.json looks like:
Then the phpunit bootstrap.php file in tests directory:
This is phpunit.xml form the same dir:
Don't forget to load your application classes in test setup. You can do it cakephp way. For example if your controller is named calendar your calendarTest.php may look like:
The same for models, vendor classes and so on. Works great for me.