Dispatcher =& new TestTestTaskMockShellDispatcher(); $this->Dispatcher->shellPaths = Configure::read('shellPaths'); $this->Task =& new MockViewTask($this->Dispatcher); $this->Task->Dispatch =& $this->Dispatcher; $this->Task->Template =& new TemplateTask($this->Dispatcher); $this->Task->Controller =& new ViewTaskMockControllerTask(); } /** * tearDown method * * @return void * @access public */ function endTest() { ClassRegistry::flush(); } /** * Test getContent and parsing of Templates. * * @return void **/ function testGetContent() { $vars = array( 'modelClass' => 'TestViewModel', 'schema' => array(), 'primaryKey' => 'id', 'displayField' => 'name', 'singularVar' => 'testViewModel', 'pluralVar' => 'testViewModels', 'singularHumanName' => 'Test View Model', 'pluralHumanName' => 'Test View Models', 'fields' => array('id', 'name', 'body'), 'associations' => array() ); $result = $this->Task->getContent('view', $vars); $this->assertPattern('/Delete Test View Model/', $result); $this->assertPattern('/Edit Test View Model/', $result); $this->assertPattern('/List Test View Models/', $result); $this->assertPattern('/New Test View Model/', $result); $this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'id\'\]/', $result); $this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'name\'\]/', $result); $this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'body\'\]/', $result); } /** * test Bake method * * @return void **/ function testBake() { $this->Task->path = TMP; $this->Task->controllerName = 'ViewTaskComments'; $this->Task->controllerPath = 'view_task_comments'; $this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'view.ctp', '*')); $this->Task->bake('view', true); $this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'edit.ctp', '*')); $this->Task->bake('edit', true); $this->Task->expectAt(2, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*')); $this->Task->bake('index', true); @rmdir(TMP . 'view_task_comments'); } /** * test bake actions baking multiple actions. * * @return void **/ function testBakeActions() { $this->Task->path = TMP; $this->Task->controllerName = 'ViewTaskComments'; $this->Task->controllerPath = 'view_task_comments'; $this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'view.ctp', '*')); $this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'edit.ctp', '*')); $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'); } /** * test baking a customAction (non crud) * * @return void **/ function testCustomAction() { $this->Task->path = TMP; $this->Task->controllerName = 'ViewTaskComments'; $this->Task->controllerPath = 'view_task_comments'; $this->Task->params['app'] = APP; $this->Task->setReturnValueAt(0, 'in', ''); $this->Task->setReturnValueAt(1, 'in', 'my_action'); $this->Task->setReturnValueAt(2, 'in', 'y'); $this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'my_action.ctp', '*')); $this->Task->customAction(); @rmdir(TMP . 'view_task_comments'); } /** * Test all() * * @return void **/ function testExecuteIntoAll() { $this->Task->path = TMP; $this->Task->args[0] = 'all'; $this->Task->Controller->setReturnValue('listAll', array('view_task_comments')); $this->Task->Controller->expectOnce('listAll'); $this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*')); $this->Task->expectAt(1, 'createFile', array(TMP . 'view_task_comments' . DS . 'view.ctp', '*')); $this->Task->expectAt(2, 'createFile', array(TMP . 'view_task_comments' . DS . 'add.ctp', '*')); $this->Task->expectAt(3, 'createFile', array(TMP . 'view_task_comments' . DS . 'edit.ctp', '*')); $this->Task->execute(); @rmdir(TMP . 'view_task_comments'); } } ?>