Permalink
Browse files

Making constructClasses() call run against the correct object. test c…

…ases updated.


Fixes #4
  • Loading branch information...
1 parent b731408 commit 31d136ca6773f5eddf28dd2c3c86aa557a0cfc4f @markstory markstory committed Aug 6, 2009
Showing with 5 additions and 3 deletions.
  1. +2 −1 cake/console/libs/tasks/test.php
  2. +3 −2 cake/tests/cases/console/libs/tasks/test.test.php
@@ -391,7 +391,8 @@ function generateConstructor($type, $fullClassName) {
return "ClassRegistry::init('$fullClassName');\n";
}
if ($type == 'controller') {
- return "new Test$fullClassName();\n\t\t\$this->{$fullClassName}->constructClasses();\n";
+ $className = substr($fullClassName, 0, strlen($fullClassName) - 10);
+ return "new Test$fullClassName();\n\t\t\$this->{$className}->constructClasses();\n";
}
return "new $fullClassName()\n";
}
@@ -362,7 +362,8 @@ function testBakeControllerTest() {
$this->assertPattern('/function redirect\(\$url, \$status = null, \$exit = true\)/', $result);
$this->assertPattern('/function startTest\(\)/', $result);
- $this->assertPattern("/\\\$this->TestTaskComments \=\& new TestTestTaskCommentsController()/", $result);
+ $this->assertPattern("/\\\$this->TestTaskComments \=\& new TestTestTaskCommentsController\(\)/", $result);
+ $this->assertPattern("/\\\$this->TestTaskComments->constructClasses\(\)/", $result);
$this->assertPattern('/function endTest\(\)/', $result);
$this->assertPattern('/unset\(\$this->TestTaskComments\)/', $result);
@@ -382,7 +383,7 @@ function testBakeControllerTest() {
**/
function testGenerateContsructor() {
$result = $this->Task->generateConstructor('controller', 'PostsController');
- $expected = "new TestPostsController();\n\t\t\$this->PostsController->constructClasses();\n";
+ $expected = "new TestPostsController();\n\t\t\$this->Posts->constructClasses();\n";
$this->assertEqual($result, $expected);
$result = $this->Task->generateConstructor('model', 'Post');

0 comments on commit 31d136c

Please sign in to comment.