Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

include plugin name in model tests

  • Loading branch information...
commit 6933b31be59fb88dc3b32ea0c9cd81c17fcd9351 1 parent 6aca803
@AD7six AD7six authored
View
7 lib/Cake/Console/Command/Task/TestTask.php
@@ -139,7 +139,7 @@ public function bake($type, $className) {
$methods = $this->getTestableMethods($fullClassName);
}
$mock = $this->hasMockClass($type, $fullClassName);
- list($preConstruct, $construction, $postConstruct) = $this->generateConstructor($type, $fullClassName);
+ list($preConstruct, $construction, $postConstruct) = $this->generateConstructor($type, $fullClassName, $plugin);
$uses = $this->generateUses($type, $realType, $fullClassName);
$this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET);
@@ -446,13 +446,14 @@ public function hasMockClass($type) {
*
* @param string $type The Type of object you are generating tests for eg. controller
* @param string $fullClassName The Classname of the class the test is being generated for.
+ * @param string $plugin The plugin name.
* @return array Constructor snippets for the thing you are building.
*/
- public function generateConstructor($type, $fullClassName) {
+ public function generateConstructor($type, $fullClassName, $plugin) {
$type = strtolower($type);
$pre = $post = '';
if ($type == 'model') {
- $construct = "ClassRegistry::init('$fullClassName');\n";
+ $construct = "ClassRegistry::init('{$plugin}$fullClassName');\n";
}
if ($type == 'behavior') {
$construct = "new $fullClassName();\n";
View
6 lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
@@ -555,15 +555,15 @@ public function testBakeHelperTest() {
* @return void
*/
public function testGenerateConstructor() {
- $result = $this->Task->generateConstructor('controller', 'PostsController');
+ $result = $this->Task->generateConstructor('controller', 'PostsController', null);
$expected = array('', "new TestPostsController();\n", "\$this->Posts->constructClasses();\n");
$this->assertEquals($expected, $result);
- $result = $this->Task->generateConstructor('model', 'Post');
+ $result = $this->Task->generateConstructor('model', 'Post', null);
$expected = array('', "ClassRegistry::init('Post');\n", '');
$this->assertEquals($expected, $result);
- $result = $this->Task->generateConstructor('helper', 'FormHelper');
+ $result = $this->Task->generateConstructor('helper', 'FormHelper', null);
$expected = array("\$View = new View();\n", "new FormHelper(\$View);\n", '');
$this->assertEquals($expected, $result);
}
Please sign in to comment.
Something went wrong with that request. Please try again.