diff --git a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php index 0e8f1913eb51..4f4469fe832a 100644 --- a/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php +++ b/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php @@ -290,9 +290,7 @@ protected function withCommandRouting(array $paths) */ public function withSchedule(callable $callback) { - $this->app->afterResolving(ConsoleKernel::class, function (ConsoleKernel $kernel) use ($callback) { - Artisan::starting(fn () => $callback($this->app->make(Schedule::class))); - }); + Artisan::starting(fn () => $callback($this->app->make(Schedule::class))); return $this; } diff --git a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php index cde9883d8242..830fb0be5f79 100644 --- a/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php +++ b/tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php @@ -77,13 +77,6 @@ public function testRunUsingChoices() ) ->expectsOutputToContain('Running [callback]'); } - - protected function tearDown(): void - { - parent::tearDown(); - - Carbon::setTestNow(null); - } } class BarCommandStub extends Command diff --git a/tests/Integration/Foundation/Configuration/WithScheduleTest.php b/tests/Integration/Foundation/Configuration/WithScheduleTest.php new file mode 100644 index 000000000000..767727f233be --- /dev/null +++ b/tests/Integration/Foundation/Configuration/WithScheduleTest.php @@ -0,0 +1,41 @@ + 80); + } + + protected function tearDown(): void + { + ScheduleListCommand::resolveTerminalWidthUsing(null); + + parent::tearDown(); + } + + protected function resolveApplication() + { + return Application::configure(static::applicationBasePath()) + ->withSchedule(function ($schedule) { + $schedule->command('schedule:clear-cache')->everyMinute(); + })->create(); + } + + public function testDisplaySchedule() + { + $this->artisan(ScheduleListCommand::class) + ->assertSuccessful() + ->expectsOutputToContain(' * * * * * php artisan schedule:clear-cache'); + } +}