getMock('Cake\Console\ConsoleOutput', [], [], '', false); $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'Cake\Console\Command\BakeShell', ['in', 'out', 'hr', 'err', 'createFile', '_stop'], [$out, $out, $in] ); Configure::write('App.namespace', 'TestApp'); } /** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); unset($this->Shell); } /** * test bake all * * @return void */ public function testAllWithModelName() { $this->Shell->Model = $this->getMock('Cake\Console\Command\Task\ModelTask'); $this->Shell->Controller = $this->getMock('Cake\Console\Command\Task\ControllerTask'); $this->Shell->View = $this->getMock('Cake\Console\Command\Task\ModelTask'); $this->Shell->Model->expects($this->once()) ->method('bake') ->with('Comments') ->will($this->returnValue(true)); $this->Shell->Controller->expects($this->once()) ->method('bake') ->with('Comments') ->will($this->returnValue(true)); $this->Shell->View->expects($this->once()) ->method('execute'); $this->Shell->expects($this->at(0)) ->method('out') ->with('Bake All'); $this->Shell->expects($this->at(2)) ->method('out') ->with('Bake All complete'); $this->Shell->connection = ''; $this->Shell->params = []; $this->Shell->args = ['Comment']; $this->Shell->all(); $this->assertEquals('Comments', $this->Shell->View->args[0]); } /** * Test the main function. * * @return void */ public function testMain() { $this->Shell->expects($this->at(0)) ->method('out') ->with($this->stringContains('The following commands')); $this->Shell->expects($this->at(3)) ->method('out') ->with('model'); $this->Shell->main(); } }