Skip to content

Commit 5ab0bca

Browse files
authored
Improve logfile lines (#46531)
1 parent e081830 commit 5ab0bca

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/Integration/Console/CommandSchedulingTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ protected function tearDown(): void
6565
/**
6666
* @dataProvider executionProvider
6767
*/
68-
public function testExecutionOrder($background)
68+
public function testExecutionOrder($background, $expected)
6969
{
7070
$event = $this->app->make(Schedule::class)
7171
->command("test:{$this->id}")
7272
->onOneServer()
7373
->after(function () {
74-
$this->fs->append($this->logfile, "after\n");
74+
$this->fs->append($this->logfile, "foreground:after\n");
7575
})
7676
->before(function () {
77-
$this->fs->append($this->logfile, "before\n");
77+
$this->fs->append($this->logfile, "foreground:before\n");
7878
});
7979

8080
if ($background) {
@@ -89,17 +89,17 @@ public function testExecutionOrder($background)
8989
if ($background) {
9090
// Since our command is running in a separate process, we need to wait
9191
// until it has finished executing before running our assertions.
92-
$this->waitForLogMessages('before', 'handled', 'after');
92+
$this->waitForLogMessages(...$expected);
9393
}
9494

95-
$this->assertLogged('before', 'handled', 'after');
95+
$this->assertLogged(...$expected);
9696
}
9797

9898
public static function executionProvider()
9999
{
100100
return [
101-
'Foreground' => [false],
102-
'Background' => [true],
101+
'Foreground' => [false, ['foreground:before', 'handled', 'foreground:after']],
102+
'Background' => [true, ['foreground:before', 'handled', 'background:after']],
103103
];
104104
}
105105

@@ -184,11 +184,11 @@ public function handle()
184184
\$schedule->command("test:{$this->id}")
185185
->after(function() use (\$fs) {
186186
\$logfile = {$logfile};
187-
\$fs->append(\$logfile, "after\\n");
187+
\$fs->append(\$logfile, "background:after\\n");
188188
})
189189
->before(function() use (\$fs) {
190190
\$logfile = {$logfile};
191-
\$fs->append(\$logfile, "before\\n");
191+
\$fs->append(\$logfile, "background:before\\n");
192192
});
193193
});
194194
});

0 commit comments

Comments
 (0)