Skip to content

Commit

Permalink
Add test for error an improve error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 5, 2014
1 parent a0670aa commit f4f608c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Console/Command/Task/TemplateTask.php
Expand Up @@ -138,7 +138,8 @@ public function getThemePath() {
$this->params['theme'] = 'default';
}
if (!isset($this->templatePaths[$this->params['theme']])) {
throw new \RuntimeException('Unable to locate templates to bake with.');
$msg = sprintf('Unable to locate "%s" bake theme templates.', $this->params['theme']);
throw new \RuntimeException($msg);
}
$this->_io->verbose(sprintf('Using "%s" bake theme', $this->params['theme']));
return $this->templatePaths[$this->params['theme']];
Expand Down
14 changes: 14 additions & 0 deletions tests/TestCase/Console/Command/Task/TemplateTaskTest.php
Expand Up @@ -59,6 +59,20 @@ public function testFindingInstalledThemesForBake() {
$this->assertPathEquals($this->Task->templatePaths['default'], $consoleLibs . 'Templates/default/');
}

/**
* test using an invalid theme name.
*
* @expectedException \RuntimeException
* @expectedExceptionMessage Unable to locate "nope" bake theme
* @return void
*/
public function testGetThemePathInvalid() {
$defaultTheme = CAKE . 'Console/Templates/default/';
$this->Task->templatePaths = ['default' => $defaultTheme];
$this->Task->params['theme'] = 'nope';
$this->Task->getThemePath();
}

/**
* test getting the correct theme name. Ensure that with only one theme, or a theme param
* that the user is not bugged. If there are more, find and return the correct theme name
Expand Down

0 comments on commit f4f608c

Please sign in to comment.