/** * test Constructor generation ensure that constructClasses is called for controllers * * @return void */ public function testGenerateConstructor() { $result = $this->Task->generateConstructor('controller', 'PostsController'); $expected = ['', '', '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('table', 'App\\Model\\Table\\PostsTable'); $expected = ["\$config = TableRegistry::exists('Posts') ? [] : ['className' => 'App\\Model\\Table\\PostsTable'];", "TableRegistry::get('Posts', \$config);", '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('helper', 'FormHelper'); $expected = ["\$view = new View();", "new FormHelper(\$view);", '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('entity', 'TestBake\\Model\\Entity\\Article'); $expected = ["", "new Article();", '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('shell_helper', 'TestBake\\Shell\\Helper\\ExampleHelper'); $expected = ["\$this->stub = new ConsoleOutput();\n \$this->io = new ConsoleIo(\$this->stub);", "new ExampleHelper(\$this->io);", '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('form', 'TestBake\\Form\\ExampleForm'); $expected = ['', "new ExampleForm();", '']; $this->assertEquals($expected, $result); }