Skip to content

Commit

Permalink
Updating tasks to not take ShellDispatcher as a parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 24, 2010
1 parent 5edb277 commit c169de6
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 55 deletions.
13 changes: 6 additions & 7 deletions cake/tests/cases/console/shells/tasks/controller.test.php
Expand Up @@ -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));
}

/**
Expand All @@ -96,7 +95,7 @@ public function setUp() {
* @return void
*/
public function teardown() {
unset($this->Task, $this->Dispatcher);
unset($this->Task);
ClassRegistry::flush();
}

Expand Down
8 changes: 4 additions & 4 deletions cake/tests/cases/console/shells/tasks/db_config.test.php
Expand Up @@ -63,10 +63,9 @@ public function setUp() {
$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;
Expand All @@ -80,7 +79,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
unset($this->Task, $this->Dispatcher);
unset($this->Task);
}

/**
Expand Down Expand Up @@ -115,9 +114,10 @@ public function testExecuteIntoInteractive() {
$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');
Expand Down
19 changes: 12 additions & 7 deletions cake/tests/cases/console/shells/tasks/extract.test.php
Expand Up @@ -42,8 +42,11 @@ public function setUp() {
$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)
);
}

/**
Expand All @@ -53,7 +56,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
unset($this->Task, $this->Dispatcher);
unset($this->Task);
}

/**
Expand All @@ -69,8 +72,10 @@ public function testExecute() {

$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'));
Expand Down Expand Up @@ -158,8 +163,8 @@ function testExtractMultiplePaths() {
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');
Expand Down
13 changes: 6 additions & 7 deletions cake/tests/cases/console/shells/tasks/fixture.test.php
Expand Up @@ -52,17 +52,16 @@ public function setUp() {
$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();
}

Expand All @@ -73,7 +72,7 @@ public function setUp() {
*/
public function tearDown() {
parent::tearDown();
unset($this->Task, $this->Dispatcher);
unset($this->Task);
}

/**
Expand All @@ -85,7 +84,7 @@ public function testConstruct() {
$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);
}

Expand Down
13 changes: 6 additions & 7 deletions cake/tests/cases/console/shells/tasks/model.test.php
Expand Up @@ -54,10 +54,9 @@ public function setUp() {
$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();
}
Expand All @@ -73,7 +72,7 @@ protected function _useMockedOut() {

$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();
}
Expand All @@ -87,9 +86,9 @@ protected function _setupOtherMocks() {
$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;
Expand All @@ -102,7 +101,7 @@ protected function _setupOtherMocks() {
*/
public function tearDown() {
parent::tearDown();
unset($this->Task, $this->Dispatcher);
unset($this->Task);
}

/**
Expand Down
6 changes: 2 additions & 4 deletions cake/tests/cases/console/shells/tasks/plugin.test.php
Expand Up @@ -47,10 +47,9 @@ public function setUp() {
$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;

Expand Down Expand Up @@ -156,8 +155,7 @@ public function testExecuteWithOneArg() {
$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();

Expand Down
5 changes: 2 additions & 3 deletions cake/tests/cases/console/shells/tasks/project.test.php
Expand Up @@ -44,10 +44,9 @@ public function setUp() {
$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;
}
Expand All @@ -62,7 +61,7 @@ public function tearDown() {

$Folder = new Folder($this->Task->path . 'bake_test_app');
$Folder->delete();
unset($this->Dispatcher, $this->Task);
unset($this->Task);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions cake/tests/cases/console/shells/tasks/template.test.php
Expand Up @@ -43,10 +43,9 @@ public function setup() {
$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)
);
}

Expand All @@ -57,7 +56,7 @@ public function setup() {
*/
public function tearDown() {
parent::tearDown();
unset($this->Task, $this->Dispatcher);
unset($this->Task);
}

/**
Expand Down Expand Up @@ -117,7 +116,7 @@ public function testGetThemePath() {
$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');
}

/**
Expand Down
11 changes: 5 additions & 6 deletions cake/tests/cases/console/shells/tasks/test.test.php
Expand Up @@ -245,13 +245,12 @@ public function setup() {
$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);
}

/**
Expand All @@ -261,7 +260,7 @@ public function setup() {
*/
public function tearDown() {
parent::tearDown();
unset($this->Task, $this->Dispatcher);
unset($this->Task);
}

/**
Expand All @@ -270,8 +269,8 @@ public function tearDown() {
* @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';

Expand Down
11 changes: 5 additions & 6 deletions cake/tests/cases/console/shells/tasks/view.test.php
Expand Up @@ -227,15 +227,14 @@ public function setUp() {
$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';
Expand Down

0 comments on commit c169de6

Please sign in to comment.