File tree Expand file tree Collapse file tree 3 files changed +42
-10
lines changed
src/Illuminate/Foundation/Configuration Expand file tree Collapse file tree 3 files changed +42
-10
lines changed Original file line number Diff line number Diff line change @@ -290,9 +290,7 @@ protected function withCommandRouting(array $paths)
290
290
*/
291
291
public function withSchedule (callable $ callback )
292
292
{
293
- $ this ->app ->afterResolving (ConsoleKernel::class, function (ConsoleKernel $ kernel ) use ($ callback ) {
294
- Artisan::starting (fn () => $ callback ($ this ->app ->make (Schedule::class)));
295
- });
293
+ Artisan::starting (fn () => $ callback ($ this ->app ->make (Schedule::class)));
296
294
297
295
return $ this ;
298
296
}
Original file line number Diff line number Diff line change @@ -77,13 +77,6 @@ public function testRunUsingChoices()
77
77
)
78
78
->expectsOutputToContain ('Running [callback] ' );
79
79
}
80
-
81
- protected function tearDown (): void
82
- {
83
- parent ::tearDown ();
84
-
85
- Carbon::setTestNow (null );
86
- }
87
80
}
88
81
89
82
class BarCommandStub extends Command
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Illuminate \Tests \Integration \Foundation \Configuration ;
4
+
5
+ use Illuminate \Console \Scheduling \ScheduleListCommand ;
6
+ use Illuminate \Foundation \Application ;
7
+ use Illuminate \Support \Carbon ;
8
+ use Orchestra \Testbench \TestCase ;
9
+
10
+ class WithScheduleTest extends TestCase
11
+ {
12
+ protected function setUp (): void
13
+ {
14
+ parent ::setUp ();
15
+
16
+ Carbon::setTestNow ('2023-01-01 ' );
17
+ ScheduleListCommand::resolveTerminalWidthUsing (fn () => 80 );
18
+ }
19
+
20
+ protected function tearDown (): void
21
+ {
22
+ ScheduleListCommand::resolveTerminalWidthUsing (null );
23
+
24
+ parent ::tearDown ();
25
+ }
26
+
27
+ protected function resolveApplication ()
28
+ {
29
+ return Application::configure (static ::applicationBasePath ())
30
+ ->withSchedule (function ($ schedule ) {
31
+ $ schedule ->command ('schedule:clear-cache ' )->everyMinute ();
32
+ })->create ();
33
+ }
34
+
35
+ public function testDisplaySchedule ()
36
+ {
37
+ $ this ->artisan (ScheduleListCommand::class)
38
+ ->assertSuccessful ()
39
+ ->expectsOutputToContain (' * * * * * php artisan schedule:clear-cache ' );
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments