Skip to content

Commit

Permalink
Making constructClasses() call run against the correct object. test c…
Browse files Browse the repository at this point in the history
…ases updated.

Fixes #4
  • Loading branch information
markstory committed Aug 12, 2009
1 parent b731408 commit 31d136c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cake/console/libs/tasks/test.php
Expand Up @@ -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";
}
Expand Down
5 changes: 3 additions & 2 deletions cake/tests/cases/console/libs/tasks/test.test.php
Expand Up @@ -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);
Expand All @@ -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');
Expand Down

0 comments on commit 31d136c

Please sign in to comment.