Skip to content

Commit 2cae043

Browse files
committed
Adding tests for interactive mode.
Fixing notice error.
1 parent 8bcd8ff commit 2cae043

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

cake/console/libs/tasks/controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function __interactive() {
190190
}
191191

192192
if ($this->interactive === true) {
193-
$this->confirmController($controllerName, $useDynamicScaffold, $uses, $helpers, $components);
193+
$this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components);
194194
$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');
195195

196196
if (strtolower($looksGood) == 'y') {

cake/tests/cases/console/libs/tasks/controller.test.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,36 @@ function testBakeActionsWithNoSessions() {
304304

305305
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
306306
$this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false);
307+
$this->assertTrue(strpos($result, "\$this->set(compact('tags'))") !== false);
307308

308309
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
309310
$this->assertTrue(strpos($result, 'if ($this->Article->del($id))') !== false);
310311
$this->assertTrue(strpos($result, "\$this->flash(__('Article deleted', true), array('action'=>'index'))") !== false);
311312
}
312313

314+
/**
315+
* test Interactive mode.
316+
*
317+
* @return void
318+
**/
319+
function testInteractive() {
320+
$this->Task->connection = 'test_suite';
321+
$this->Task->path = '/my/path';
322+
$this->Task->setReturnValueAt(0, 'in', '1');
323+
$this->Task->setReturnValueAt(1, 'in', 'y'); // build interactive
324+
$this->Task->setReturnValueAt(2, 'in', 'n'); // build no scaffolds
325+
$this->Task->setReturnValueAt(3, 'in', 'y'); // build normal methods
326+
$this->Task->setReturnValueAt(4, 'in', 'n'); // build admin methods
327+
$this->Task->setReturnValueAt(5, 'in', 'n'); // helpers?
328+
$this->Task->setReturnValueAt(6, 'in', 'n'); // components?
329+
$this->Task->setReturnValueAt(7, 'in', 'y'); // use sessions
330+
$this->Task->setReturnValueAt(8, 'in', 'y'); // looks good
331+
332+
$this->Task->execute();
333+
334+
$filename = '/my/path/articles_controller.php';
335+
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
336+
}
313337
/**
314338
* test that execute runs all when the first arg == all
315339
*

0 commit comments

Comments
 (0)