Skip to content

Commit 61ea0bc

Browse files
authored
[10.x] Add displayName for queued Artisan commands (#48778)
* Add `displayName` for queued Artisan commands * Match handle method
1 parent cee91ab commit 61ea0bc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Illuminate/Foundation/Console/QueuedCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ public function handle(KernelContract $kernel)
3939
{
4040
$kernel->call(...array_values($this->data));
4141
}
42+
43+
/**
44+
* Get the display name for the queued job.
45+
*
46+
* @return string
47+
*/
48+
public function displayName()
49+
{
50+
return array_values($this->data)[0];
51+
}
4252
}

tests/Integration/Console/ConsoleApplicationTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Console\Command;
66
use Illuminate\Console\Scheduling\Schedule;
77
use Illuminate\Contracts\Console\Kernel;
8+
use Illuminate\Foundation\Console\QueuedCommand;
9+
use Illuminate\Support\Facades\Queue;
810
use Orchestra\Testbench\TestCase;
911

1012
class ConsoleApplicationTest extends TestCase
@@ -65,6 +67,19 @@ public function testArtisanInstantiateScheduleWhenNeed()
6567

6668
$this->assertTrue($this->app->resolved(Schedule::class));
6769
}
70+
71+
public function testArtisanQueue()
72+
{
73+
Queue::fake();
74+
75+
$this->app[Kernel::class]->queue('foo:bar', [
76+
'id' => 1,
77+
]);
78+
79+
Queue::assertPushed(QueuedCommand::class, function ($job) {
80+
return $job->displayName() === 'foo:bar';
81+
});
82+
}
6883
}
6984

7085
class FooCommandStub extends Command

0 commit comments

Comments
 (0)