mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
include plugin name in model tests
This commit is contained in:
parent
6aca8036f4
commit
6933b31be5
2 changed files with 7 additions and 6 deletions
|
@ -139,7 +139,7 @@ class TestTask extends BakeTask {
|
||||||
$methods = $this->getTestableMethods($fullClassName);
|
$methods = $this->getTestableMethods($fullClassName);
|
||||||
}
|
}
|
||||||
$mock = $this->hasMockClass($type, $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);
|
$uses = $this->generateUses($type, $realType, $fullClassName);
|
||||||
|
|
||||||
$this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET);
|
$this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET);
|
||||||
|
@ -446,13 +446,14 @@ class TestTask extends BakeTask {
|
||||||
*
|
*
|
||||||
* @param string $type The Type of object you are generating tests for eg. controller
|
* @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 $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.
|
* @return array Constructor snippets for the thing you are building.
|
||||||
*/
|
*/
|
||||||
public function generateConstructor($type, $fullClassName) {
|
public function generateConstructor($type, $fullClassName, $plugin) {
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
$pre = $post = '';
|
$pre = $post = '';
|
||||||
if ($type == 'model') {
|
if ($type == 'model') {
|
||||||
$construct = "ClassRegistry::init('$fullClassName');\n";
|
$construct = "ClassRegistry::init('{$plugin}$fullClassName');\n";
|
||||||
}
|
}
|
||||||
if ($type == 'behavior') {
|
if ($type == 'behavior') {
|
||||||
$construct = "new $fullClassName();\n";
|
$construct = "new $fullClassName();\n";
|
||||||
|
|
|
@ -555,15 +555,15 @@ class TestTaskTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGenerateConstructor() {
|
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");
|
$expected = array('', "new TestPostsController();\n", "\$this->Posts->constructClasses();\n");
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Task->generateConstructor('model', 'Post');
|
$result = $this->Task->generateConstructor('model', 'Post', null);
|
||||||
$expected = array('', "ClassRegistry::init('Post');\n", '');
|
$expected = array('', "ClassRegistry::init('Post');\n", '');
|
||||||
$this->assertEquals($expected, $result);
|
$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", '');
|
$expected = array("\$View = new View();\n", "new FormHelper(\$View);\n", '');
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue