Adding test generation for controllers baked with ControllerTask::all()

This commit is contained in:
mark_story 2009-07-15 10:14:16 -04:00
parent 80b9692856
commit 1e8d01992e
2 changed files with 9 additions and 2 deletions

View file

@ -113,12 +113,15 @@ class ControllerTask extends Shell {
$this->interactive = false;
$this->listAll($this->connection, false);
ClassRegistry::config('Model', array('ds' => $this->connection));
$unitTestExists = $this->_checkUnitTest();
foreach ($this->__tables as $table) {
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
if (App::import('Model', $model)) {
$actions = $this->bakeActions($controller);
$this->bake($controller, $actions);
if ($this->bake($controller, $actions) && $unitTestExists) {
$this->bakeTest($controller);
}
}
}
}

View file

@ -104,6 +104,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->Template->params['theme'] = 'default';
$this->Task->Model =& new ControllerMockModelTask($this->Task->Dispatch);
$this->Task->Project =& new ControllerMockProjectTask($this->Task->Dispatch);
$this->Task->Test =& new ControllerMockTestTask();
}
/**
@ -368,7 +369,6 @@ class ControllerTaskTest extends CakeTestCase {
function testBakeTest() {
$this->Task->plugin = 'ControllerTest';
$this->Task->connection = 'test_suite';
$this->Task->Test =& new ControllerMockTestTask();
$this->Task->Test->expectOnce('bake', array('Controller', 'Articles'));
$this->Task->bakeTest('Articles');
@ -416,6 +416,10 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->setReturnValue('createFile', true);
$this->Task->setReturnValue('_checkUnitTest', true);
$this->Task->Test->expectCallCount('bake', 1);
$filename = '/my/path/articles_controller.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));