Skip to content

Commit

Permalink
Adding tests for other object types.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 25, 2009
1 parent 975aab8 commit 66b36ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cake/console/libs/tasks/test.php
Expand Up @@ -390,12 +390,12 @@ function generateMockClass($type, $class) {
function generateConstructor($type, $fullClassName) {
$type = strtolower($type);
if ($type == 'model') {
return "ClassRegistry::init('$fullClassName');";
return "ClassRegistry::init('$fullClassName');\n";
}
if ($type == 'controller') {
return "new Test$fullClassName();\n\t\t\$this->{$fullClassName}->constructClasses();";
return "new Test$fullClassName();\n\t\t\$this->{$fullClassName}->constructClasses();\n";
}
return "new $fullClassName";
return "new $fullClassName()\n";
}

/**
Expand Down
10 changes: 9 additions & 1 deletion cake/tests/cases/console/libs/tasks/test.test.php
Expand Up @@ -312,7 +312,15 @@ function testBake() {
**/
function testGenerateContsructor() {
$result = $this->Task->generateConstructor('controller', 'PostsController');
$expected = "new TestPostsController();\n\t\t\$this->PostsController->constructClasses();";
$expected = "new TestPostsController();\n\t\t\$this->PostsController->constructClasses();\n";
$this->assertEqual($result, $expected);

$result = $this->Task->generateConstructor('model', 'Post');
$expected = "ClassRegistry::init('Post');\n";
$this->assertEqual($result, $expected);

$result = $this->Task->generateConstructor('helper', 'FormHelper');
$expected = "new FormHelper()\n";
$this->assertEqual($result, $expected);
}
}
Expand Down

0 comments on commit 66b36ba

Please sign in to comment.