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

[9.x] Adds expectsOutputToContain to the PendingCommand. #40984

Merged
merged 2 commits into from
Feb 16, 2022
Merged

[9.x] Adds expectsOutputToContain to the PendingCommand. #40984

merged 2 commits into from
Feb 16, 2022

Conversation

xiCO2k
Copy link
Contributor

@xiCO2k xiCO2k commented Feb 13, 2022

Hey guys,

This PR adds a method to the PendingCommand to be used for testing.

The main reason is to test if the output contains a text, I found this really helpful, to use for the CLI output, its like the assertSee method from the Http response.

Example

$this->artisan('Hello World')
      ->expectsOutputToContain('Hello');

Hope that helps,

Thanks,
Francisco.

@driesvints
Copy link
Member

Hi, I've fixed the tests on 9.x so please rebase your PR and mark your PR as ready when tests pass. Thanks

@driesvints driesvints marked this pull request as draft February 14, 2022 08:26
@xiCO2k
Copy link
Contributor Author

xiCO2k commented Feb 14, 2022

sure thing! Thanks @driesvints

@xiCO2k xiCO2k marked this pull request as ready for review February 14, 2022 08:35
@stancl
Copy link
Contributor

stancl commented Sep 29, 2022

@xiCO2k I noticed that the behavior is a bit different than expectsOutput() which may be confusing to the user. It seems that with expectsOutputToContain(), you need to actually trigger the command with something else, such as assertExitCode(0) in the test you PR'd here.

But if you simply swap expectsOutput() to expectsOutputToContain(), the test will make no assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants