getMock('Cake\Console\ConsoleIo', [], [], '', false); $this->Task = $this->getMock('Cake\Shell\Task\TemplateTask', array('in', 'err', 'createFile', '_stop', 'clear'), array($io) ); } /** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); unset($this->Task); } /** * test generate * * @return void */ public function testGenerate() { $this->Task->initialize(); $this->Task->expects($this->any())->method('in')->will($this->returnValue(1)); $result = $this->Task->generate('classes', 'test_object', array('test' => 'foo')); $expected = "I got rendered\nfoo"; $this->assertTextEquals($expected, $result); } /** * test generate with a missing template in the chosen template. * ensure fallback to default works. * * @return void */ public function testGenerateWithTemplateFallbacks() { $this->Task->initialize(); $this->Task->params['template'] = 'test'; $this->Task->set(array( 'name' => 'Articles', 'table' => 'articles', 'import' => false, 'records' => false, 'schema' => '', 'namespace' => '' )); $result = $this->Task->generate('classes', 'fixture'); $this->assertRegExp('/ArticlesFixture extends .*TestFixture/', $result); } }