You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: console-tests.md
+23-5Lines changed: 23 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ Laravel allows you to easily "mock" user input for your console commands using t
58
58
$this->line('Your name is '.$name.' and you prefer '.$language.'.');
59
59
});
60
60
61
-
You may test this command with the following test which utilizes the `expectsQuestion`, `expectsOutput`, `doesntExpectOutput`, `expectsOutputToContain`, `doesntExpectOutputToContain`, and `assertExitCode` methods:
61
+
You may test this command with the following test:
62
62
63
63
```php tab=Pest
64
64
test('console command', function () {
@@ -67,8 +67,6 @@ test('console command', function () {
67
67
->expectsQuestion('Which language do you prefer?', 'PHP')
68
68
->expectsOutput('Your name is Taylor Otwell and you prefer PHP.')
69
69
->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.')
70
-
->expectsOutputToContain('Taylor Otwell')
71
-
->doesntExpectOutputToContain('you prefer Ruby')
72
70
->assertExitCode(0);
73
71
});
74
72
```
@@ -84,8 +82,6 @@ public function test_console_command(): void
84
82
->expectsQuestion('Which language do you prefer?', 'PHP')
85
83
->expectsOutput('Your name is Taylor Otwell and you prefer PHP.')
86
84
->doesntExpectOutput('Your name is Taylor Otwell and you prefer Ruby.')
87
-
->expectsOutputToContain('Taylor Otwell')
88
-
->doesntExpectOutputToContain('you prefer Ruby')
89
85
->assertExitCode(0);
90
86
}
91
87
```
@@ -110,6 +106,28 @@ public function test_console_command(): void
110
106
->doesntExpectOutput()
111
107
->assertExitCode(0);
112
108
}
109
+
```
110
+
111
+
The `expectsOutputToContain` and `doesntExpectOutputToContain` methods may be used to make assertions against a portion of the output:
0 commit comments