Skip to content
Permalink
Browse files

Updating ViewTask to use the ProjectTask.

Adding tests for previously missed code branch.
  • Loading branch information...
markstory committed Jul 1, 2009
1 parent 0eef657 commit 11ecde194d4af25cd49309f8ecb12d210585a0c7
Showing with 33 additions and 27 deletions.
  1. +1 −1 cake/console/libs/tasks/view.php
  2. +32 −26 cake/tests/cases/console/libs/tasks/view.test.php
@@ -211,7 +211,7 @@ function __interactive() {
$this->bakeActions($actions, $vars);
}
if (strtolower($wannaDoAdmin) == 'y') {
$admin = $this->getAdmin();
$admin = $this->Project->getAdmin();
$regularActions = $this->scaffoldActions;
$adminActions = array();
foreach ($regularActions as $action) {
@@ -38,11 +38,12 @@
ob_end_clean();
}
if (!class_exists('TestTask')) {
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'view.php';
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'controller.php';
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
}
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'view.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'controller.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php';
Mock::generatePartial(
'ShellDispatcher', 'TestTestTaskMockShellDispatcher',
@@ -54,6 +55,7 @@
);
Mock::generate('ControllerTask', 'ViewTaskMockControllerTask');
Mock::generate('ProjectTask', 'ViewTaskMockProjectTask');
class ViewTaskComment extends Model {
var $name = 'ViewTaskComment';
@@ -106,6 +108,8 @@ function startTest() {
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->Template =& new TemplateTask($this->Dispatcher);
$this->Task->Controller =& new ViewTaskMockControllerTask();
$this->Task->Project =& new ViewTaskMockProjectTask();
$this->Task->path = TMP;
}
/**
@@ -154,7 +158,6 @@ function testGetContent() {
* @return void
**/
function testBake() {
$this->Task->path = TMP;
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
@@ -172,8 +175,6 @@ function testBake() {
new PatternExpectation('/\$viewTaskComment\[\'Article\'\]\[\'title\'\]/')
));
$this->Task->bake('index', true);
@rmdir(TMP . 'view_task_comments');
}
/**
@@ -182,7 +183,6 @@ function testBake() {
* @return void
**/
function testBakeWithPlugin() {
$this->Task->path = TMP;
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->plugin = 'TestTest';
@@ -198,7 +198,6 @@ function testBakeWithPlugin() {
* @return void
**/
function testBakeActions() {
$this->Task->path = TMP;
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
@@ -207,8 +206,6 @@ function testBakeActions() {
$this->Task->expectAt(2, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->bakeActions(array('view', 'edit', 'index'), array());
@rmdir(TMP . 'view_task_comments');
}
/**
@@ -217,7 +214,6 @@ function testBakeActions() {
* @return void
**/
function testCustomAction() {
$this->Task->path = TMP;
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';
$this->Task->params['app'] = APP;
@@ -228,8 +224,6 @@ function testCustomAction() {
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'my_action.ctp', '*'));
$this->Task->customAction();
@rmdir(TMP . 'view_task_comments');
}
/**
@@ -238,7 +232,6 @@ function testCustomAction() {
* @return void
**/
function testExecuteIntoAll() {
$this->Task->path = TMP;
$this->Task->args[0] = 'all';
$this->Task->Controller->setReturnValue('listAll', array('view_task_comments'));
@@ -251,8 +244,6 @@ function testExecuteIntoAll() {
$this->Task->expectAt(3, 'createFile', array(TMP . 'view_task_comments' . DS . 'edit.ctp', '*'));
$this->Task->execute();
@rmdir(TMP . 'view_task_comments');
}
/**
@@ -261,15 +252,12 @@ function testExecuteIntoAll() {
* @return void
**/
function testExecuteWithActionParam() {
$this->Task->path = TMP;
$this->Task->args[0] = 'ViewTaskComments';
$this->Task->args[1] = 'view';
$this->Task->expectCallCount('createFile', 1);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'view.ctp', '*'));
$this->Task->execute();
@rmdir(TMP . 'view_task_comments');
}
/**
@@ -278,15 +266,12 @@ function testExecuteWithActionParam() {
* @return void
**/
function testExecuteWithController() {
$this->Task->path = TMP;
$this->Task->args[0] = 'ViewTaskComments';
$this->Task->expectCallCount('createFile', 2);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'add.ctp', '*'));
$this->Task->execute();
@rmdir(TMP . 'view_task_comments');
}
/**
@@ -295,7 +280,6 @@ function testExecuteWithController() {
* @return void
**/
function testExecuteInteractive() {
$this->Task->path = TMP;
$this->Task->connection = 'test_suite';
$this->Task->args = array();
@@ -312,8 +296,30 @@ function testExecuteInteractive() {
$this->Task->expectAt(3, 'createFile', array(TMP . 'view_task_comments' . DS . 'edit.ctp', '*'));
$this->Task->execute();
}
@rmdir(TMP . 'view_task_comments');
/**
* test execute into interactive() with admin methods.
*
* @return void
**/
function testExecuteInteractiveWithAdmin() {
$this->Task->connection = 'test_suite';
$this->Task->args = array();
$this->Task->Controller->setReturnValue('getName', 'ViewTaskComments');
$this->Task->Project->setReturnValue('getAdmin', 'admin_');
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'n');
$this->Task->setReturnValueAt(2, 'in', 'y');
$this->Task->expectCallCount('createFile', 4);
$this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'admin_index.ctp', '*'));
$this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'admin_view.ctp', '*'));
$this->Task->expectAt(2, 'createFile', array(TMP . 'view_task_comments' . DS . 'admin_add.ctp', '*'));
$this->Task->expectAt(3, 'createFile', array(TMP . 'view_task_comments' . DS . 'admin_edit.ctp', '*'));
$this->Task->execute();
}
}
?>

0 comments on commit 11ecde1

Please sign in to comment.
You can’t perform that action at this time.