Skip to content

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

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
xiCO2k:feat/add-expects-output-to-contain
Feb 16, 2022
Merged

taylorotwell merged 2 commits into
laravel:9.xfrom
xiCO2k:feat/add-expects-output-to-contain

Conversation

@xiCO2k

@xiCO2k xiCO2k commented Feb 13, 2022 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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

xiCO2k commented Feb 14, 2022

Copy link
Copy Markdown
Member Author

sure thing! Thanks @driesvints

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

stancl commented Sep 29, 2022

Copy link
Copy Markdown
Contributor

@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.

salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
…#40984)

* feat: Adds `expectsOutputToContain` to the `PendingCommand`.

* formatting

Co-authored-by: Taylor Otwell <taylor@laravel.com>
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