Note: This repo is no longer under active development. These improvements were contributed to the CakePHP core in the 2.0-dev stage. Please take a look at the docs for more info. This plugin is still plenty usable for projects still on the CakePHP 1.3 branch.
Extended test case aims to make the displeasure of using
CakeTestCase::testAction()
slightly more pleasurable.
Above your test case, use:
App::import('Lib', 'ExtendedTestCase.ExtendedTestCase');
Then extend your test case with ExtendedTestCase
instead of CakeTestCase
and
define the testController
variable in your test case as the controller you are
testing.
For more information about utilizing mocks, etc. visit here.
Another handy feature that ExtendedTestCase
adds is the ability to just test
certain methods. This is especially useful when you are making minor changes to
one method (say, a controller method) who's test lies in a large test case that
loads a lot of fixtures. While testing internally, you can conveniently add an
array of methods that you want to run in a $testMethods
var on your test case.
class MyTestCase extends ExtendedTestCase {
var $testMethods = array('testThis');
function testThis() {} // will run
function testThat() {} // will not run
}
Since no other tests run, you'll only need to load the database and fixtures for the method you care about at the time.
Remember to remove $testMethods
before you commit anything :)
- Falls back to old
testAction
method ifExtendedTestCase::testController
is not defined - Allows use of mocks for things like the Email component or your controller actions (render, header, etc.) in tests
- Simulates most of what the controller action does, minus actually rendering anything
- Allows testing a subset of test methods within a large test case
Licensed under The MIT License http://www.opensource.org/licenses/mit-license.php Redistributions of files must retain the above copyright notice.