Skip to content

Commit

Permalink
Add a test for default command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
kodie committed Nov 19, 2024
1 parent e813ef7 commit 526dae6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,21 @@ public function testDefaultCommand()
$app = $this->newApp('test');

// Add some sample commands to the application
$app->command('command1');
$app->command('command1')->action(function () {
echo 'This should be the default command';
});
$app->command('command2');

// Test setting a valid default command
$app->defaultCommand('command1');
$this->assertEquals('command1', $app->getDefaultCommand());

// Test executing a default command
ob_start();
$app->handle(['test']);
$buffer = ob_get_clean();
$this->assertSame('This should be the default command', $buffer);

// Test setting an invalid default command
$this->expectException(InvalidArgumentException::class);
$app->defaultCommand('invalid_command');
Expand Down

0 comments on commit 526dae6

Please sign in to comment.