From c169de60e2a4103f7e25d35ee97440143b27d05a Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 24 Oct 2010 15:27:04 -0400 Subject: [PATCH] Updating tasks to not take ShellDispatcher as a parameter. --- .../console/shells/tasks/controller.test.php | 13 ++++++------- .../console/shells/tasks/db_config.test.php | 8 ++++---- .../console/shells/tasks/extract.test.php | 19 ++++++++++++------- .../console/shells/tasks/fixture.test.php | 13 ++++++------- .../cases/console/shells/tasks/model.test.php | 13 ++++++------- .../console/shells/tasks/plugin.test.php | 6 ++---- .../console/shells/tasks/project.test.php | 5 ++--- .../console/shells/tasks/template.test.php | 7 +++---- .../cases/console/shells/tasks/test.test.php | 11 +++++------ .../cases/console/shells/tasks/view.test.php | 11 +++++------ 10 files changed, 51 insertions(+), 55 deletions(-) diff --git a/cake/tests/cases/console/shells/tasks/controller.test.php b/cake/tests/cases/console/shells/tasks/controller.test.php index 1961d0906..dae95bced 100644 --- a/cake/tests/cases/console/shells/tasks/controller.test.php +++ b/cake/tests/cases/console/shells/tasks/controller.test.php @@ -68,26 +68,25 @@ class ControllerTaskTest extends CakeTestCase { * @return void */ public function setUp() { - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); $this->Task = $this->getMock('ControllerTask', array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->name = 'Controller'; - $this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in); + $this->Task->Template = new TemplateTask($out, $out, $in); $this->Task->Template->params['theme'] = 'default'; $this->Task->Model = $this->getMock('ModelTask', array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->Project = $this->getMock('ProjectTask', array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest', 'getPrefix'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); - $this->Task->Test = $this->getMock('TestTask', array(), array(&$this->Dispatcher, $out, $out, $in)); + $this->Task->Test = $this->getMock('TestTask', array(), array($out, $out, $in)); } /** @@ -96,7 +95,7 @@ class ControllerTaskTest extends CakeTestCase { * @return void */ public function teardown() { - unset($this->Task, $this->Dispatcher); + unset($this->Task); ClassRegistry::flush(); } diff --git a/cake/tests/cases/console/shells/tasks/db_config.test.php b/cake/tests/cases/console/shells/tasks/db_config.test.php index c29e4b72c..5429e9723 100644 --- a/cake/tests/cases/console/shells/tasks/db_config.test.php +++ b/cake/tests/cases/console/shells/tasks/db_config.test.php @@ -63,10 +63,9 @@ class DbConfigTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('DbConfigTask', array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->path = APP . 'config' . DS; @@ -80,7 +79,7 @@ class DbConfigTaskTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->Task, $this->Dispatcher); + unset($this->Task); } /** @@ -115,9 +114,10 @@ class DbConfigTaskTest extends CakeTestCase { $this->Task->initialize(); $out = $this->getMock('ConsoleOutput', array(), array(), '', false); + $in = $this->getMock('ConsoleInput', array(), array(), '', false); $this->Task = $this->getMock( 'DbConfigTask', - array('in', '_stop', 'createFile', 'bake'), array(&$this->Dispatcher, $out, $out) + array('in', '_stop', 'createFile', 'bake'), array($out, $out, $in) ); $this->Task->expects($this->once())->method('_stop'); diff --git a/cake/tests/cases/console/shells/tasks/extract.test.php b/cake/tests/cases/console/shells/tasks/extract.test.php index b7a583bb4..b2c802a5d 100644 --- a/cake/tests/cases/console/shells/tasks/extract.test.php +++ b/cake/tests/cases/console/shells/tasks/extract.test.php @@ -42,8 +42,11 @@ class ExtractTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); - $this->Task = new ExtractTask($this->Dispatcher, $out, $out, $in); + $this->Task = $this->getMock( + 'ExtractTask', + array('in', 'out', 'err', '_stop'), + array($out, $out, $in) + ); } /** @@ -53,7 +56,7 @@ class ExtractTaskTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->Task, $this->Dispatcher); + unset($this->Task); } /** @@ -69,8 +72,10 @@ class ExtractTaskTest extends CakeTestCase { $this->Task->params['paths'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages'; $this->Task->params['output'] = $path . DS; - $this->Dispatcher->expects($this->never())->method('stderr'); - $this->Dispatcher->expects($this->never())->method('_stop'); + $this->Task->expects($this->never())->method('err'); + $this->Task->expects($this->any())->method('in') + ->will($this->returnValue('y')); + $this->Task->expects($this->never())->method('_stop'); $this->Task->execute(); $this->assertTrue(file_exists($path . DS . 'default.pot')); @@ -158,8 +163,8 @@ class ExtractTaskTest extends CakeTestCase { TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'posts'; $this->Task->params['output'] = $path . DS; - $this->Task->Dispatch->expects($this->never())->method('stderr'); - $this->Task->Dispatch->expects($this->never())->method('_stop'); + $this->Task->expects($this->never())->method('err'); + $this->Task->expects($this->never())->method('_stop'); $this->Task->execute(); $result = file_get_contents($path . DS . 'default.pot'); diff --git a/cake/tests/cases/console/shells/tasks/fixture.test.php b/cake/tests/cases/console/shells/tasks/fixture.test.php index 42716af1e..ce397bef7 100644 --- a/cake/tests/cases/console/shells/tasks/fixture.test.php +++ b/cake/tests/cases/console/shells/tasks/fixture.test.php @@ -52,17 +52,16 @@ class FixtureTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('FixtureTask', array('in', 'err', 'createFile', '_stop', 'clear'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->Model = $this->getMock('Shell', array('in', 'out', 'error', 'createFile', 'getName', 'getTable', 'listAll'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); - $this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in); - $this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher, $out, $out, $in)); + $this->Task->Template = new TemplateTask($out, $out, $in); + $this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array($out, $out, $in)); $this->Task->Template->initialize(); } @@ -73,7 +72,7 @@ class FixtureTaskTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->Task, $this->Dispatcher); + unset($this->Task); } /** @@ -85,7 +84,7 @@ class FixtureTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $Task = new FixtureTask($this->Dispatcher, $out, $out, $in); + $Task = new FixtureTask($out, $out, $in); $this->assertEqual($Task->path, APP . 'tests' . DS . 'fixtures' . DS); } diff --git a/cake/tests/cases/console/shells/tasks/model.test.php b/cake/tests/cases/console/shells/tasks/model.test.php index 4e121b278..b2072fdeb 100644 --- a/cake/tests/cases/console/shells/tasks/model.test.php +++ b/cake/tests/cases/console/shells/tasks/model.test.php @@ -54,10 +54,9 @@ class ModelTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('ModelTask', array('in', 'err', 'createFile', '_stop', '_checkUnitTest'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->_setupOtherMocks(); } @@ -73,7 +72,7 @@ class ModelTaskTest extends CakeTestCase { $this->Task = $this->getMock('ModelTask', array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->_setupOtherMocks(); } @@ -87,9 +86,9 @@ class ModelTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Task->Fixture = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in)); - $this->Task->Test = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in)); - $this->Task->Template = new TemplateTask($this->Task->Dispatch, $out, $out, $in); + $this->Task->Fixture = $this->getMock('FixtureTask', array(), array($out, $out, $in)); + $this->Task->Test = $this->getMock('FixtureTask', array(), array($out, $out, $in)); + $this->Task->Template = new TemplateTask($out, $out, $in); $this->Task->name = 'Model'; $this->Task->interactive = true; @@ -102,7 +101,7 @@ class ModelTaskTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->Task, $this->Dispatcher); + unset($this->Task); } /** diff --git a/cake/tests/cases/console/shells/tasks/plugin.test.php b/cake/tests/cases/console/shells/tasks/plugin.test.php index 2730072a6..327b258c2 100644 --- a/cake/tests/cases/console/shells/tasks/plugin.test.php +++ b/cake/tests/cases/console/shells/tasks/plugin.test.php @@ -47,10 +47,9 @@ class PluginTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('PluginTask', array('in', 'err', 'createFile', '_stop', 'clear'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->path = TMP . 'tests' . DS; @@ -156,8 +155,7 @@ class PluginTaskTest extends CakeTestCase { $this->Task->expects($this->at(3))->method('createFile') ->with($file, new PHPUnit_Framework_Constraint_IsAnything()); - $this->Task->Dispatch->args = array('BakeTestPlugin'); - $this->Task->args =& $this->Task->Dispatch->args; + $this->Task->args = array('BakeTestPlugin'); $this->Task->execute(); diff --git a/cake/tests/cases/console/shells/tasks/project.test.php b/cake/tests/cases/console/shells/tasks/project.test.php index e0aff9bd7..9b9581fb2 100644 --- a/cake/tests/cases/console/shells/tasks/project.test.php +++ b/cake/tests/cases/console/shells/tasks/project.test.php @@ -44,10 +44,9 @@ class ProjectTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment', 'clear')); $this->Task = $this->getMock('ProjectTask', array('in', 'err', 'createFile', '_stop'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->path = TMP . 'tests' . DS; } @@ -62,7 +61,7 @@ class ProjectTaskTest extends CakeTestCase { $Folder = new Folder($this->Task->path . 'bake_test_app'); $Folder->delete(); - unset($this->Dispatcher, $this->Task); + unset($this->Task); } /** diff --git a/cake/tests/cases/console/shells/tasks/template.test.php b/cake/tests/cases/console/shells/tasks/template.test.php index 08cba89e5..744ed43a0 100644 --- a/cake/tests/cases/console/shells/tasks/template.test.php +++ b/cake/tests/cases/console/shells/tasks/template.test.php @@ -43,10 +43,9 @@ class TemplateTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('TemplateTask', array('in', 'err', 'createFile', '_stop', 'clear'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); } @@ -57,7 +56,7 @@ class TemplateTaskTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->Task, $this->Dispatcher); + unset($this->Task); } /** @@ -117,7 +116,7 @@ class TemplateTaskTest extends CakeTestCase { $this->Task->params = array(); $result = $this->Task->getThemePath(); $this->assertEqual($result, $defaultTheme); - $this->assertEqual($this->Dispatcher->params['theme'], 'default'); + $this->assertEqual($this->Task->params['theme'], 'default'); } /** diff --git a/cake/tests/cases/console/shells/tasks/test.test.php b/cake/tests/cases/console/shells/tasks/test.test.php index e5794ccf6..d8fa87ead 100644 --- a/cake/tests/cases/console/shells/tasks/test.test.php +++ b/cake/tests/cases/console/shells/tasks/test.test.php @@ -245,13 +245,12 @@ class TestTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('TestTask', array('in', 'err', 'createFile', '_stop', 'isLoadableClass'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $this->Task->name = 'Test'; - $this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in); + $this->Task->Template = new TemplateTask($out, $out, $in); } /** @@ -261,7 +260,7 @@ class TestTaskTest extends CakeTestCase { */ public function tearDown() { parent::tearDown(); - unset($this->Task, $this->Dispatcher); + unset($this->Task); } /** @@ -270,8 +269,8 @@ class TestTaskTest extends CakeTestCase { * @return void */ public function testFilePathGenerationModelRepeated() { - $this->Dispatcher->expects($this->never())->method('stderr'); - $this->Dispatcher->expects($this->never())->method('_stop'); + $this->Task->expects($this->never())->method('err'); + $this->Task->expects($this->never())->method('_stop'); $file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php'; diff --git a/cake/tests/cases/console/shells/tasks/view.test.php b/cake/tests/cases/console/shells/tasks/view.test.php index 9f2bf9400..41db3ed52 100644 --- a/cake/tests/cases/console/shells/tasks/view.test.php +++ b/cake/tests/cases/console/shells/tasks/view.test.php @@ -227,15 +227,14 @@ class ViewTaskTest extends CakeTestCase { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment')); $this->Task = $this->getMock('ViewTask', array('in', 'err', 'createFile', '_stop'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); - $this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in); - $this->Task->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher, $out, $out, $in)); - $this->Task->Project = $this->getMock('ProjectTask', array(), array(&$this->Dispatcher, $out, $out, $in)); - $this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher, $out, $out, $in)); + $this->Task->Template = new TemplateTask($out, $out, $in); + $this->Task->Controller = $this->getMock('ControllerTask', array(), array($out, $out, $in)); + $this->Task->Project = $this->getMock('ProjectTask', array(), array($out, $out, $in)); + $this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array($out, $out, $in)); $this->Task->path = TMP; $this->Task->Template->params['theme'] = 'default';