From 8e93c4cd349f20ee5fa67307db599bb1d4671ca0 Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Tue, 28 Feb 2012 14:58:28 +0000 Subject: [PATCH] Fix for Consolce/Task/TestTask::getRealClassName(). Controller names of exactly 10 letters being returned incorrectly Signed-off-by: mark_story --- lib/Cake/Console/Command/Task/TestTask.php | 5 ++++- lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 66646f597..b9d8b0373 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -274,7 +274,10 @@ class TestTask extends BakeTask { if (strtolower($type) == 'model' || empty($this->classTypes[$type])) { return $class; } - if (strlen($class) - strpos($class, $type) == strlen($type)) { + + $position = strpos($class, $type); + + if ($position !== false && strlen($class) - $position == strlen($type)) { return $class; } return $class . $type; diff --git a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php index cb7fe00c9..3dcd27839 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php @@ -403,6 +403,9 @@ class TestTaskTest extends CakeTestCase { $result = $this->Task->getRealClassname('Controller', 'PostsController'); $this->assertEquals('PostsController', $result); + + $result = $this->Task->getRealClassname('Controller', 'AlertTypes'); + $this->assertEquals('AlertTypesController', $result); $result = $this->Task->getRealClassname('Helper', 'Form'); $this->assertEquals('FormHelper', $result);