Example #1
0
 /**
  * Sets up this test case
  *
  */
 public function setUp()
 {
     $this->mockObjectManager = $this->getMock('TYPO3\\FLOW3\\Object\\ObjectManagerInterface');
     $this->mockObjectManager->expects($this->any())->method('getObjectNameByClassName')->with('Acme\\Test\\Command\\DefaultCommandController')->will($this->returnValue('Acme\\Test\\Command\\DefaultCommandController'));
     $this->mockCommand = $this->getMock('TYPO3\\FLOW3\\Cli\\Command', array(), array(), '', FALSE);
     $this->mockCommand->expects($this->any())->method('getControllerClassName')->will($this->returnValue('Acme\\Test\\Command\\DefaultCommandController'));
     $this->mockCommand->expects($this->any())->method('getControllerCommandName')->will($this->returnValue('list'));
     $this->mockCommandManager = $this->getMock('TYPO3\\FLOW3\\Cli\\CommandManager');
     $this->mockCommandManager->expects($this->any())->method('getCommandByIdentifier')->with('acme.test:default:list')->will($this->returnValue($this->mockCommand));
     $this->mockReflectionService = $this->getMock('TYPO3\\FLOW3\\Reflection\\ReflectionService');
     $this->requestBuilder = new \TYPO3\FLOW3\Cli\RequestBuilder();
     $this->requestBuilder->injectObjectManager($this->mockObjectManager);
     $this->requestBuilder->injectReflectionService($this->mockReflectionService);
     $this->requestBuilder->injectCommandManager($this->mockCommandManager);
 }
Example #2
0
 /**
  * @test
  */
 public function getShortestIdentifierForCommandReturnsCompleteCommandIdentifierForCommandsWithTheSameControllerAndCommandName()
 {
     $mockCommand1 = $this->getMock('TYPO3\\FLOW3\\Cli\\Command', array(), array(), '', FALSE);
     $mockCommand1->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('package.key:controller:command'));
     $mockCommand2 = $this->getMock('TYPO3\\FLOW3\\Cli\\Command', array(), array(), '', FALSE);
     $mockCommand2->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('otherpackage.key:controller:command'));
     $mockCommands = array($mockCommand1, $mockCommand2);
     $this->commandManager->expects($this->atLeastOnce())->method('getAvailableCommands')->will($this->returnValue($mockCommands));
     $this->assertSame('package.key:controller:command', $this->commandManager->getShortestIdentifierForCommand($mockCommand1));
     $this->assertSame('otherpackage.key:controller:command', $this->commandManager->getShortestIdentifierForCommand($mockCommand2));
 }