Browse Source

Fix an issue when generating tests for lowercase type names.

mark_story 12 years ago
parent
commit
08289ba1e2

+ 7 - 7
src/Console/Command/Task/TestTask.php

@@ -66,12 +66,12 @@ class TestTask extends BakeTask {
  * @var array
  */
 	public $classSuffixes = [
-		'Entity' => '',
-		'Table' => 'Table',
-		'Controller' => 'Controller',
-		'Component' => 'Component',
-		'Behavior' => 'Behavior',
-		'Helper' => 'Helper'
+		'entity' => '',
+		'table' => 'Table',
+		'controller' => 'Controller',
+		'component' => 'Component',
+		'behavior' => 'Behavior',
+		'helper' => 'Helper'
 	];
 
 /**
@@ -264,7 +264,7 @@ class TestTask extends BakeTask {
 		if ($this->plugin) {
 			$namespace = Plugin::getNamespace($this->plugin);
 		}
-		$suffix = $this->classSuffixes[$type];
+		$suffix = $this->classSuffixes[strtolower($type)];
 		$subSpace = $this->mapType($type);
 		if ($suffix && strpos($class, $suffix) === false) {
 			$class .= $suffix;

+ 6 - 6
tests/TestCase/Console/Command/Task/TestTaskTest.php

@@ -264,17 +264,17 @@ class TestTaskTest extends TestCase {
 	public static function realClassProvider() {
 		return [
 			['Entity', 'Article', 'App\Model\Entity\Article'],
-			['Entity', 'ArticleEntity', 'App\Model\Entity\ArticleEntity'],
+			['entity', 'ArticleEntity', 'App\Model\Entity\ArticleEntity'],
 			['Table', 'Posts', 'App\Model\Table\PostsTable'],
-			['Table', 'PostsTable', 'App\Model\Table\PostsTable'],
+			['table', 'PostsTable', 'App\Model\Table\PostsTable'],
 			['Controller', 'Posts', 'App\Controller\PostsController'],
-			['Controller', 'PostsController', 'App\Controller\PostsController'],
+			['controller', 'PostsController', 'App\Controller\PostsController'],
 			['Behavior', 'Timestamp', 'App\Model\Behavior\TimestampBehavior'],
-			['Behavior', 'TimestampBehavior', 'App\Model\Behavior\TimestampBehavior'],
+			['behavior', 'TimestampBehavior', 'App\Model\Behavior\TimestampBehavior'],
 			['Helper', 'Form', 'App\View\Helper\FormHelper'],
-			['Helper', 'FormHelper', 'App\View\Helper\FormHelper'],
+			['helper', 'FormHelper', 'App\View\Helper\FormHelper'],
 			['Component', 'Auth', 'App\Controller\Component\AuthComponent'],
-			['Component', 'AuthComponent', 'App\Controller\Component\AuthComponent'],
+			['component', 'AuthComponent', 'App\Controller\Component\AuthComponent'],
 		];
 	}