/** * Verify correct dispatch of Shell subclasses without a main method * * @return void */ public function testDispatchShellWithoutMain() { $Dispatcher = new TestShellDispatcher(); $Shell = $this->getMock('Shell', array(), array(&$Dispatcher), 'MockWithoutMainShell'); $Shell = new MockWithoutMainShell($Dispatcher); $this->mockObjects[] = $Shell; $Shell->expects($this->once())->method('initialize'); $Shell->expects($this->once())->method('loadTasks'); $Shell->expects($this->once())->method('runCommand')->with('initdb', array('initdb'))->will($this->returnValue(true)); $Dispatcher->TestShell = $Shell; $Dispatcher->args = array('mock_without_main', 'initdb'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); }
/** * Verify correct dispatch of Shell subclasses without a main method * * @return void * @access public */ function testDispatchShellWithoutMain() { Mock::generate('Shell', 'MockWithoutMainShell', array('initDb', '_secret')); $Dispatcher =& new TestShellDispatcher(); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectOnce('initialize'); $Shell->expectOnce('loadTasks'); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectOnce('startup'); $Shell->expectOnce('initDb'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'initdb'); $result = $Dispatcher->dispatch(); $this->assertTrue($result); $this->assertEqual($Dispatcher->args, array()); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('startup'); $Shell->expectNever('hr'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'hr'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $this->assertEqual($Dispatcher->args, array('hr')); $Shell = new MockWithoutMainShell(); $Shell->setReturnValue('initDb', true); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'dispatch'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainShell(); $Shell->expectNever('startup'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', 'idontexist'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); $Shell = new MockWithoutMainShell(); $Shell->expectNever('startup'); $Shell->expectNever('_secret'); $Dispatcher->TestShell =& $Shell; $Dispatcher->args = array('mock_without_main', '_secret'); $result = $Dispatcher->dispatch(); $this->assertFalse($result); }