Dispatcher = $this->getMock( 'ShellDispatcher', array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment') ); $this->Shell = $this->getMock( 'BakeShell', array('in', 'out', 'hr', 'err', 'createFile', '_stop', '_checkUnitTest'), array(&$this->Dispatcher) ); $this->Shell->Dispatch->shellPaths = App::path('shells'); } /** * endTest method * * @return void */ public function endTest() { unset($this->Dispatch, $this->Shell); } /** * test bake all * * @return void */ public function testAllWithModelName() { App::import('Model', 'User'); $userExists = class_exists('User'); if ($this->skipIf($userExists, 'User class exists, cannot test `bake all [param]`. %s')) { return; } $this->Shell->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher)); $this->Shell->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher)); $this->Shell->View = $this->getMock('ModelTask', array(), array(&$this->Dispatcher)); $this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher)); $this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test')); $this->Shell->Model->expects($this->never())->method('getName'); $this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true)); $this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true)); $this->Shell->View->expects($this->once())->method('execute'); $this->Shell->expects($this->at(1))->method('out')->with('Bake All'); $this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.'); $this->Shell->expects($this->at(5))->method('out')->with('User Controller was baked.'); $this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.'); $this->Shell->expects($this->at(8))->method('out')->with('Bake All complete'); $this->Shell->params = array(); $this->Shell->args = array('User'); $this->Shell->all(); } }