Updating tasks to not take ShellDispatcher as a parameter.

This commit is contained in:
mark_story 2010-10-24 15:27:04 -04:00
parent 5edb277111
commit c169de60e2
10 changed files with 51 additions and 55 deletions

View file

@ -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();
}

View file

@ -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');

View file

@ -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');

View file

@ -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);
}

View file

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

View file

@ -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();

View file

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

View file

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

View file

@ -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';

View file

@ -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';