File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
tests/Integration/Testing Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,16 @@ public function assertSuccessful()
249
249
return $ this ->assertExitCode (Command::SUCCESS );
250
250
}
251
251
252
+ /**
253
+ * Assert that the command has the success exit code.
254
+ *
255
+ * @return $this
256
+ */
257
+ public function assertOk ()
258
+ {
259
+ return $ this ->assertSuccessful ();
260
+ }
261
+
252
262
/**
253
263
* Assert that the command does not have the success exit code.
254
264
*
Original file line number Diff line number Diff line change @@ -33,12 +33,27 @@ protected function setUp(): void
33
33
$ this ->line ($ this ->ask ('Huh? ' ));
34
34
});
35
35
36
+ Artisan::command ('exit {code} ' , fn () => (int ) $ this ->argument ('code ' ));
37
+
36
38
Artisan::command ('contains ' , function () {
37
39
$ this ->line ('My name is Taylor Otwell ' );
38
40
});
39
41
}
40
42
41
43
public function test_console_command_that_passes ()
44
+ {
45
+ $ this ->artisan ('exit ' , ['code ' => 0 ])->assertOk ();
46
+ }
47
+
48
+ public function test_console_command_that_fails ()
49
+ {
50
+ $ this ->expectException (AssertionFailedError::class);
51
+ $ this ->expectExceptionMessage ('Expected status code 0 but received 1. ' );
52
+
53
+ $ this ->artisan ('exit ' , ['code ' => 1 ])->assertOk ();
54
+ }
55
+
56
+ public function test_console_command_that_passes_with_output ()
42
57
{
43
58
$ this ->artisan ('survey ' )
44
59
->expectsQuestion ('What is your name? ' , 'Taylor Otwell ' )
You can’t perform that action at this time.
0 commit comments