Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test prompt commands #301

Open
antonio-gg-dev opened this issue Aug 1, 2024 · 0 comments
Open

Test prompt commands #301

antonio-gg-dev opened this issue Aug 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@antonio-gg-dev
Copy link
Member

It wiuld be nice to have an easy way to test commands that require user interaction, for example, as it is done with Laravel commands.

/**
 * Test a console command.
 */
public function test_console_command(): void
{
    $this->artisan('question')
         ->expectsQuestion('What is your name?', 'Taylor Otwell')
         ->expectsQuestion('Which language do you prefer?', 'PHP')
         ->expectsOutput('Your name is Taylor Otwell and you prefer PHP.')
         ->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.')
         ->assertExitCode(0);
}

https://laravel.com/docs/11.x/console-tests#input-output-expectations

@antonio-gg-dev antonio-gg-dev added the enhancement New feature or request label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant