public function setUp() { $this->commandController = $this->getAccessibleMock(CommandController::class, ['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(ConsoleOutput::class)->disableOriginalConstructor()->getMock(); $this->inject($this->commandController, 'output', $this->mockConsoleOutput); }
/** * @test * @dataProvider quotedValues */ public function quotedArgumentValuesAreCorrectlyParsedWhenPassingTheCommandAsString($quotedArgument, $expectedResult) { $methodParameters = ['requiredArgument1' => ['optional' => false, 'type' => 'string'], 'requiredArgument2' => ['optional' => false, 'type' => 'string']]; $this->mockCommandManager->expects($this->once())->method('getCommandMethodParameters')->with('Acme\\Test\\Command\\DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters)); $expectedArguments = ['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->getMockBuilder(Cli\Command::class)->disableOriginalConstructor()->getMock(); $mockCommand1->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('package.key:controller:command')); $mockCommand2 = $this->getMockBuilder(Cli\Command::class)->disableOriginalConstructor()->getMock(); $mockCommand2->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('otherpackage.key:controller:command')); $mockCommands = [$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)); }