diff --git a/src/Illuminate/Foundation/Console/QueuedCommand.php b/src/Illuminate/Foundation/Console/QueuedCommand.php index fb3d027b4b0a..43848cc263e3 100644 --- a/src/Illuminate/Foundation/Console/QueuedCommand.php +++ b/src/Illuminate/Foundation/Console/QueuedCommand.php @@ -39,4 +39,14 @@ public function handle(KernelContract $kernel) { $kernel->call(...array_values($this->data)); } + + /** + * Get the display name for the queued job. + * + * @return string + */ + public function displayName() + { + return array_values($this->data)[0]; + } } diff --git a/tests/Integration/Console/ConsoleApplicationTest.php b/tests/Integration/Console/ConsoleApplicationTest.php index 8d6a607aa46f..9daafb57c89a 100644 --- a/tests/Integration/Console/ConsoleApplicationTest.php +++ b/tests/Integration/Console/ConsoleApplicationTest.php @@ -5,6 +5,8 @@ use Illuminate\Console\Command; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Contracts\Console\Kernel; +use Illuminate\Foundation\Console\QueuedCommand; +use Illuminate\Support\Facades\Queue; use Orchestra\Testbench\TestCase; class ConsoleApplicationTest extends TestCase @@ -65,6 +67,19 @@ public function testArtisanInstantiateScheduleWhenNeed() $this->assertTrue($this->app->resolved(Schedule::class)); } + + public function testArtisanQueue() + { + Queue::fake(); + + $this->app[Kernel::class]->queue('foo:bar', [ + 'id' => 1, + ]); + + Queue::assertPushed(QueuedCommand::class, function ($job) { + return $job->displayName() === 'foo:bar'; + }); + } } class FooCommandStub extends Command