CakePHP: Testing

Similar to the testing we did in Zend Framework, CakePHP’s unit tests depend on PHPUnit, making it an easy end to our time in CakePHP.


  • We need to learn how to create and run tests on our controllers.


There are a few simple tests that we can create in order to validate the functionality of our CakePHP controllers. Because the majority of code we have written in CakePHP concerns the controller, we will only write tests for some of the actions in the UsersController.

CakePHP unit tests need to be placed n the ~/app/Test/ directory, and the first set of tests that we will create are shown in Listing 33-1 ...

Get Pro PHP MVC now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.