/** * @test */ public function getCommandsByIdentifierReturnsAllCommandsOfTheSpecifiedPackage() { $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:controller2:command')); $mockCommand3 = $this->getMock('TYPO3\\FLOW3\\Cli\\Command', array(), array(), '', FALSE); $mockCommand3->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('packagekey:controller:command')); $mockCommand4 = $this->getMock('TYPO3\\FLOW3\\Cli\\Command', array(), array(), '', FALSE); $mockCommand4->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('packagekey:controller:othercommand')); $mockCommands = array($mockCommand1, $mockCommand2, $mockCommand3, $mockCommand4); $this->commandManager->expects($this->once())->method('getAvailableCommands')->will($this->returnValue($mockCommands)); $expectedResult = array($mockCommand3, $mockCommand4); $this->assertSame($expectedResult, $this->commandManager->getCommandsByIdentifier('packagekey')); }
/** * Display help for a command * * The help command displays help for a given command: * ./flow3 help <commandIdentifier> * * @param string $commandIdentifier Identifier of a command for more details * @return void */ public function helpCommand($commandIdentifier = NULL) { $exceedingArguments = $this->request->getExceedingArguments(); if (count($exceedingArguments) > 0 && $commandIdentifier === NULL) { $commandIdentifier = $exceedingArguments[0]; } if ($commandIdentifier === NULL) { $this->displayHelpIndex(); } else { $matchingCommands = $this->commandManager->getCommandsByIdentifier($commandIdentifier); $numberOfMatchingCommands = count($matchingCommands); if ($numberOfMatchingCommands === 0) { $this->outputLine('No command could be found that matches the command identifier "%s".', array($commandIdentifier)); } elseif ($numberOfMatchingCommands > 1) { $this->outputLine('%d commands match the command identifier "%s":', array($numberOfMatchingCommands, $commandIdentifier)); $this->displayShortHelpForCommands($matchingCommands); } else { $this->displayHelpForCommand(array_shift($matchingCommands)); } } }