Skip to content

Commit

Permalink
Updating TemplateTask test cases to use PHPUnit.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 9, 2010
1 parent ac68f5c commit f09a5bd
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions cake/tests/cases/console/libs/tasks/template.test.php
Expand Up @@ -35,16 +35,6 @@

require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';

Mock::generatePartial(
'ShellDispatcher', 'TestTemplateTaskMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
);

Mock::generatePartial(
'TemplateTask', 'MockTemplateTask',
array('in', 'out', 'err', 'createFile', '_stop')
);

/**
* TemplateTaskTest class
*
Expand All @@ -59,9 +49,13 @@ class TemplateTaskTest extends CakeTestCase {
* @return void
*/
public function startTest() {
$this->Dispatcher =& new TestTemplateTaskMockShellDispatcher();
$this->Task =& new MockTemplateTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment'
));
$this->Task = $this->getMock('TemplateTask',
array('in', 'err', 'createFile', '_stop'),
array(&$this->Dispatcher)
);
$this->Task->Dispatch->shellPaths = App::path('shells');
}

Expand Down Expand Up @@ -113,7 +107,8 @@ public function testFindingInstalledThemesForBake() {
public function testGetThemePath() {
$defaultTheme = CAKE_CORE_INCLUDE_PATH . DS . dirname(CONSOLE_LIBS) . 'templates' . DS . 'default' .DS;
$this->Task->templatePaths = array('default' => $defaultTheme);
$this->Task->expectCallCount('in', 1);

$this->Task->expects($this->exactly(1))->method('in')->will($this->returnValue('1'));

$result = $this->Task->getThemePath();
$this->assertEqual($result, $defaultTheme);
Expand All @@ -124,7 +119,6 @@ public function testGetThemePath() {
$this->assertEqual($result, '/some/path');

$this->Task->params = array();
$this->Task->setReturnValueAt(0, 'in', '1');
$result = $this->Task->getThemePath();
$this->assertEqual($result, $defaultTheme);
$this->assertEqual($this->Dispatcher->params['theme'], 'default');
Expand All @@ -142,7 +136,8 @@ public function testGenerate() {
)
));
$this->Task->initialize();
$this->Task->setReturnValue('in', 1);
$this->Task->expects($this->any())->method('in')->will($this->returnValue(1));

$result = $this->Task->generate('classes', 'test_object', array('test' => 'foo'));
$expected = "I got rendered\nfoo";
$this->assertEqual($result, $expected);
Expand Down

0 comments on commit f09a5bd

Please sign in to comment.