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); } /** * 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'); } } ?>