Skip to content

Commit

Permalink
Document parser problem with a failing test, and mark it skipped.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Dec 21, 2016
1 parent 1f1d928 commit f8567e3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/src/ExampleCommandFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down
25 changes: 25 additions & 0 deletions tests/testAnnotatedCommandFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]] [--] [<args>]...', $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;
Expand Down

0 comments on commit f8567e3

Please sign in to comment.