public function setUp()
 {
     $this->commandController = $this->getAccessibleMock(\TYPO3\Flow\Cli\CommandController::class, array('resolveCommandMethodName', 'callCommandMethod'));
     $this->mockCommandManager = $this->getMockBuilder(CommandManager::class)->disableOriginalConstructor()->getMock();
     $this->mockCommandManager->expects($this->any())->method('getCommandMethodParameters')->will($this->returnValue(array()));
     $this->inject($this->commandController, 'commandManager', $this->mockCommandManager);
     $this->mockConsoleOutput = $this->getMockBuilder(\TYPO3\Flow\Cli\ConsoleOutput::class)->disableOriginalConstructor()->getMock();
     $this->inject($this->commandController, 'output', $this->mockConsoleOutput);
 }
 /**
  * Sets up this test case
  *
  */
 public function setUp()
 {
     $this->mockObjectManager = $this->getMock(\TYPO3\Flow\Object\ObjectManagerInterface::class);
     $this->mockObjectManager->expects($this->any())->method('getObjectNameByClassName')->with('Acme\\Test\\Command\\DefaultCommandController')->will($this->returnValue('Acme\\Test\\Command\\DefaultCommandController'));
     $this->mockCommand = $this->getMock(\TYPO3\Flow\Cli\Command::class, 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\Flow\Cli\CommandManager::class);
     $this->mockCommandManager->expects($this->any())->method('getCommandByIdentifier')->with('acme.test:default:list')->will($this->returnValue($this->mockCommand));
     $this->mockReflectionService = $this->getMock(\TYPO3\Flow\Reflection\ReflectionService::class);
     $this->requestBuilder = new \TYPO3\Flow\Cli\RequestBuilder();
     $this->requestBuilder->injectObjectManager($this->mockObjectManager);
     $this->requestBuilder->injectReflectionService($this->mockReflectionService);
     $this->requestBuilder->injectCommandManager($this->mockCommandManager);
 }
 /**
  * @test
  * @dataProvider quotedValues
  */
 public function quotedArgumentValuesAreCorrectlyParsedWhenPassingTheCommandAsString($quotedArgument, $expectedResult)
 {
     $methodParameters = array('requiredArgument1' => array('optional' => false, 'type' => 'string'), 'requiredArgument2' => array('optional' => false, 'type' => 'string'));
     $this->mockCommandManager->expects($this->once())->method('getCommandMethodParameters')->with('Acme\\Test\\Command\\DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
     $expectedArguments = array('requiredArgument1' => 'firstArgumentValue', 'requiredArgument2' => $expectedResult);
     $request = $this->requestBuilder->build('acme.test:default:list firstArgumentValue ' . $quotedArgument);
     $this->assertEquals($expectedArguments, $request->getArguments());
 }
 /**
  * @test
  */
 public function getShortestIdentifierForCommandReturnsCompleteCommandIdentifierForCommandsWithTheSameControllerAndCommandName()
 {
     $mockCommand1 = $this->getMock(\TYPO3\Flow\Cli\Command::class, array(), array(), '', false);
     $mockCommand1->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('package.key:controller:command'));
     $mockCommand2 = $this->getMock(\TYPO3\Flow\Cli\Command::class, 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));
 }