@@ -65,16 +65,16 @@ protected function tearDown(): void
65
65
/**
66
66
* @dataProvider executionProvider
67
67
*/
68
- public function testExecutionOrder ($ background )
68
+ public function testExecutionOrder ($ background, $ expected )
69
69
{
70
70
$ event = $ this ->app ->make (Schedule::class)
71
71
->command ("test: {$ this ->id }" )
72
72
->onOneServer ()
73
73
->after (function () {
74
- $ this ->fs ->append ($ this ->logfile , "after \n" );
74
+ $ this ->fs ->append ($ this ->logfile , "foreground: after \n" );
75
75
})
76
76
->before (function () {
77
- $ this ->fs ->append ($ this ->logfile , "before \n" );
77
+ $ this ->fs ->append ($ this ->logfile , "foreground: before \n" );
78
78
});
79
79
80
80
if ($ background ) {
@@ -89,17 +89,17 @@ public function testExecutionOrder($background)
89
89
if ($ background ) {
90
90
// Since our command is running in a separate process, we need to wait
91
91
// until it has finished executing before running our assertions.
92
- $ this ->waitForLogMessages (' before ' , ' handled ' , ' after ' );
92
+ $ this ->waitForLogMessages (... $ expected );
93
93
}
94
94
95
- $ this ->assertLogged (' before ' , ' handled ' , ' after ' );
95
+ $ this ->assertLogged (... $ expected );
96
96
}
97
97
98
98
public static function executionProvider ()
99
99
{
100
100
return [
101
- 'Foreground ' => [false ],
102
- 'Background ' => [true ],
101
+ 'Foreground ' => [false , [ ' foreground:before ' , ' handled ' , ' foreground:after ' ] ],
102
+ 'Background ' => [true , [ ' foreground:before ' , ' handled ' , ' background:after ' ] ],
103
103
];
104
104
}
105
105
@@ -184,11 +184,11 @@ public function handle()
184
184
\$schedule->command("test: {$ this ->id }")
185
185
->after(function() use ( \$fs) {
186
186
\$logfile = {$ logfile };
187
- \$fs->append( \$logfile, "after\\n");
187
+ \$fs->append( \$logfile, "background: after\\n");
188
188
})
189
189
->before(function() use ( \$fs) {
190
190
\$logfile = {$ logfile };
191
- \$fs->append( \$logfile, "before\\n");
191
+ \$fs->append( \$logfile, "background: before\\n");
192
192
});
193
193
});
194
194
});
0 commit comments