1
1
<?php
2
2
3
3
use Illuminate \Console \Command ;
4
+ use Illuminate \Console \Scheduling \CallbackEvent ;
4
5
use Illuminate \Console \Scheduling \Schedule ;
5
6
use Illuminate \Foundation \Console \QueuedCommand ;
6
7
use Illuminate \Support \Facades \Queue ;
7
8
9
+ it ('does not set the name when provided as a command signature ' , function () {
10
+ Queue::fake ();
11
+
12
+ /** @var Schedule $scheduler */
13
+ $ scheduler = $ this ->app ->make (Schedule::class);
14
+
15
+ /** @var CallbackEvent $event */
16
+ $ event = $ scheduler ->queueCommand ('bar:run ' );
17
+ expect ($ event ->description )
18
+ ->toBeNull ()
19
+ ->and (fn () => $ event ->withoutOverlapping ())
20
+ ->toThrow (LogicException::class);
21
+ });
22
+
23
+ it ('sets the name from the command description when provided as a class string ' , function () {
24
+ Queue::fake ();
25
+
26
+ /** @var Schedule $scheduler */
27
+ $ scheduler = $ this ->app ->make (Schedule::class);
28
+
29
+ /** @var CallbackEvent $event */
30
+ $ event = $ scheduler ->queueCommand (FooCommand::class)->withoutOverlapping ();
31
+
32
+ expect ($ event ->description )->toBe ('I am description for the foo command ' );
33
+ });
34
+
8
35
it ('sends queued command to correct queue ' , function () {
9
36
Queue::fake ();
10
37
11
38
/** @var Schedule $scheduler */
12
39
$ scheduler = $ this ->app ->make (Schedule::class);
13
- $ scheduler ->queueCommand (FooCommand::class)->name ( '' )-> everyMinute ();
14
- $ scheduler ->queueCommand (FooCommand::class , ['foo ' => 'bar ' ], 'test-queue ' )-> name ( ' ' )->everyMinute ();
40
+ $ scheduler ->queueCommand (FooCommand::class)->everyMinute ();
41
+ $ scheduler ->queueCommand (' bar:test ' , ['foo ' => 'bar ' ], 'test-queue ' )->everyMinute ();
15
42
$ scheduler ->queueCommand (FooCommand::class, ['foo ' => 'bar ' ], 'another-queue ' )->name ('' )->everyMinute ();
16
43
17
44
$ events = $ scheduler ->events ();
29
56
30
57
/** @var \Illuminate\Console\Scheduling\Schedule $scheduler */
31
58
$ scheduler = $ this ->app ->make (Schedule::class);
32
- $ scheduler ->queueCommand (FooCommand::class)->name ('' )->everyMinute ();
59
+ $ scheduler ->queueCommand (FooCommand::class)->name ('' )->everyMinute ()-> withoutOverlapping () ;
33
60
$ scheduler ->queueCommand (FooCommand::class, ['foo ' => 'bar ' ], null , 'foo ' )->name ('' )->everyMinute ();
34
- $ scheduler ->queueCommand (FooCommand::class , ['foo ' => 'bar ' ], null , 'bar ' )->name ('' )->everyMinute ();
61
+ $ scheduler ->queueCommand (' bar:test ' , ['foo ' => 'bar ' ], null , 'bar ' )->name ('' )->everyMinute ();
35
62
36
63
$ events = $ scheduler ->events ();
37
64
foreach ($ events as $ event ) {
@@ -47,6 +74,8 @@ class FooCommand extends Command
47
74
{
48
75
protected $ signature = 'foo:run ' ;
49
76
77
+ protected $ description = 'I am description for the foo command ' ;
78
+
50
79
public function handle ()
51
80
{
52
81
//
0 commit comments