Skip to content

Commit

Permalink
Fix for Consolce/Task/TestTask::getRealClassName(). Controller names …
Browse files Browse the repository at this point in the history
…of exactly 10 letters

being returned incorrectly

Signed-off-by: mark_story <mark@mark-story.com>
  • Loading branch information
robmcvey authored and markstory committed Feb 28, 2012
1 parent 757579e commit 8e93c4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -274,7 +274,10 @@ public function getRealClassName($type, $class) {
if (strtolower($type) == 'model' || empty($this->classTypes[$type])) { if (strtolower($type) == 'model' || empty($this->classTypes[$type])) {
return $class; 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;
} }
return $class . $type; return $class . $type;
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
Expand Up @@ -403,6 +403,9 @@ public function testGetRealClassname() {


$result = $this->Task->getRealClassname('Controller', 'PostsController'); $result = $this->Task->getRealClassname('Controller', 'PostsController');
$this->assertEquals('PostsController', $result); $this->assertEquals('PostsController', $result);

$result = $this->Task->getRealClassname('Controller', 'AlertTypes');
$this->assertEquals('AlertTypesController', $result);


$result = $this->Task->getRealClassname('Helper', 'Form'); $result = $this->Task->getRealClassname('Helper', 'Form');
$this->assertEquals('FormHelper', $result); $this->assertEquals('FormHelper', $result);
Expand Down

0 comments on commit 8e93c4c

Please sign in to comment.