Browse Source

Add test for error an improve error message.

mark_story 12 years ago
parent
commit
f4f608c485

+ 2 - 1
src/Console/Command/Task/TemplateTask.php

@@ -138,7 +138,8 @@ class TemplateTask extends Shell {
 			$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']];

+ 14 - 0
tests/TestCase/Console/Command/Task/TemplateTaskTest.php

@@ -60,6 +60,20 @@ class TemplateTaskTest extends TestCase {
 	}
 
 /**
+ * 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
  *