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:
Test/
Case/
Console/
Command/
Task/
MyShellTaskTest.php
MyShellTest.php
Your tests can just extend the CakeTestCase object, just like any other generic test:
class MyShellTest extends CakeTestCase {
}
If needed, you can override the base shell, just like you would do with a Controller test:
class TestMyShell extends MyShell {
}
Nothing all that special, just stick with the conventions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With