diff --git a/tests/src/ExampleCommandFile.php b/tests/src/ExampleCommandFile.php index 3c6d8a0..2e41d78 100644 --- a/tests/src/ExampleCommandFile.php +++ b/tests/src/ExampleCommandFile.php @@ -63,7 +63,15 @@ public function myRepeat($one, $two = '', $options = ['repeat' => 1]) } /** + * This is the my:join command + * + * This command will join its parameters together. It can also reverse and repeat its arguments. + * * @command my:join + * @usage a b + * Join a and b to produce "a,b" + * @usage + * Example with no parameters or options */ public function myJoin(array $args, $options = ['flip' => false, 'repeat' => 1]) { diff --git a/tests/testAnnotatedCommandFactory.php b/tests/testAnnotatedCommandFactory.php index 1a0755d..c12d3ca 100644 --- a/tests/testAnnotatedCommandFactory.php +++ b/tests/testAnnotatedCommandFactory.php @@ -86,6 +86,31 @@ function testMyCatCommand() $this->assertRunCommandViaApplicationEquals($command, $input, 'alphabet'); } + function testJoinCommandHelp() + { + $this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile; + $this->commandFactory = new AnnotatedCommandFactory(); + $commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'myJoin'); + + $command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance); + + $this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command); + $this->assertEquals('my:join', $command->getName()); + $this->assertEquals('This is the my:join command', $command->getDescription()); + $this->assertEquals("This command will join its parameters together. It can also reverse and repeat its arguments.", $command->getHelp()); + $this->assertEquals('my:join [--flip] [--repeat [REPEAT]] [--] []...', $command->getSynopsis()); + + // Bug in parser: @usage with no parameters or options not passed to us correctly. + $actualUsages = implode(',', $command->getUsages()); + if ($actualUsages == 'my:join a b,my:join Example with no parameters or options') { + $this->markTestSkipped(); + } + $this->assertEquals('my:join a b,my:join', $actualUsages); + + $input = new StringInput('my:join bet alpha --flip --repeat=2'); + $this->assertRunCommandViaApplicationEquals($command, $input, 'alphabetalphabet'); + } + function testDefaultsCommand() { $this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;