I want to write unit tests for a CakePHP shell that I’m creating, but they aren’t mentioned in the testing documentation or bake:
---------------------------------------------------------------
Bake Tests
Path: /home/brad/sites/farmlogs/app/Test/
---------------------------------------------------------------
---------------------------------------------------------------
Select an object type:
---------------------------------------------------------------
1. Model
2. Controller
3. Component
4. Behavior
5. Helper
Enter the type of object to bake a test for or (q)uit (1/2/3/4/5/q)
Since CakePHP doesn’t appear to have a default shell testing setup, what should the structure of my basic shell tests look like?
Judging from examples in Mark Story’s AssetCompress and the CakeDC’s Migrations, just mimic the directory structure for other tests:
Your tests can just extend the CakeTestCase object, just like any other generic test:
If needed, you can override the base shell, just like you would do with a Controller test:
Nothing all that special, just stick with the conventions.