mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding test generation for controllers baked with ControllerTask::all()
This commit is contained in:
parent
80b9692856
commit
1e8d01992e
2 changed files with 9 additions and 2 deletions
|
@ -113,12 +113,15 @@ class ControllerTask extends Shell {
|
||||||
$this->interactive = false;
|
$this->interactive = false;
|
||||||
$this->listAll($this->connection, false);
|
$this->listAll($this->connection, false);
|
||||||
ClassRegistry::config('Model', array('ds' => $this->connection));
|
ClassRegistry::config('Model', array('ds' => $this->connection));
|
||||||
|
$unitTestExists = $this->_checkUnitTest();
|
||||||
foreach ($this->__tables as $table) {
|
foreach ($this->__tables as $table) {
|
||||||
$model = $this->_modelName($table);
|
$model = $this->_modelName($table);
|
||||||
$controller = $this->_controllerName($model);
|
$controller = $this->_controllerName($model);
|
||||||
if (App::import('Model', $model)) {
|
if (App::import('Model', $model)) {
|
||||||
$actions = $this->bakeActions($controller);
|
$actions = $this->bakeActions($controller);
|
||||||
$this->bake($controller, $actions);
|
if ($this->bake($controller, $actions) && $unitTestExists) {
|
||||||
|
$this->bakeTest($controller);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$this->Task->Template->params['theme'] = 'default';
|
$this->Task->Template->params['theme'] = 'default';
|
||||||
$this->Task->Model =& new ControllerMockModelTask($this->Task->Dispatch);
|
$this->Task->Model =& new ControllerMockModelTask($this->Task->Dispatch);
|
||||||
$this->Task->Project =& new ControllerMockProjectTask($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() {
|
function testBakeTest() {
|
||||||
$this->Task->plugin = 'ControllerTest';
|
$this->Task->plugin = 'ControllerTest';
|
||||||
$this->Task->connection = 'test_suite';
|
$this->Task->connection = 'test_suite';
|
||||||
$this->Task->Test =& new ControllerMockTestTask();
|
|
||||||
|
|
||||||
$this->Task->Test->expectOnce('bake', array('Controller', 'Articles'));
|
$this->Task->Test->expectOnce('bake', array('Controller', 'Articles'));
|
||||||
$this->Task->bakeTest('Articles');
|
$this->Task->bakeTest('Articles');
|
||||||
|
@ -416,6 +416,10 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
$this->Task->path = '/my/path/';
|
$this->Task->path = '/my/path/';
|
||||||
$this->Task->args = array('all');
|
$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';
|
$filename = '/my/path/articles_controller.php';
|
||||||
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
|
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue