Skip to content

Commit

Permalink
Add tests of Application::runCommand() with arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaskill committed Jul 16, 2023
1 parent 50186f3 commit c48bfb0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,41 @@ public function runs_a_command()
$this->assertSame(0, $code);
}

/**
* @test
*/
public function runs_a_command_with_arguments()
{
$this->application->command('greet [name] [--yell]', function ($name, $yell, OutputInterface $output) {
if ($name) {
$text = 'Hello, '.$name;
} else {
$text = 'Hello';
}

if ($yell) {
$text = strtoupper($text);
}

$output->write($text);
});

$output = new SpyOutput();
$code = $this->application->runCommand('greet', $output);
$this->assertSame('Hello', $output->output);
$this->assertSame(0, $code);

$output = new SpyOutput();
$code = $this->application->runCommand('greet John', $output);
$this->assertSame('Hello, John', $output->output);
$this->assertSame(0, $code);

$output = new SpyOutput();
$code = $this->application->runCommand('greet John --yell', $output);
$this->assertSame('HELLO, JOHN', $output->output);
$this->assertSame(0, $code);
}

/**
* @test
*/
Expand Down

0 comments on commit c48bfb0

Please sign in to comment.