/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Queue/ListFailedCommandTest.php
69 строк
2 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Queue; use Illuminate\Foundation\Application; use Illuminate\Queue\Console\ListFailedCommand; use Mockery; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; class ListFailedCommandTest extends TestCase { public function testItDisplaysEmptyFailedJobsAsJson() { $output = $this->runCommandWithFailedJobs([], ['--json' => true]); $this->assertJson($output); $this->assertJsonStringEqualsJsonString('[]', $output); } public function testItDisplaysFailedJobsAsJson() { $output = $this->runCommandWithFailedJobs([ (object) [ 'id' => 'failed-job-id', 'connection' => 'redis', 'queue' => 'default', 'payload' => json_encode([ 'job' => 'Illuminate\Queue\CallQueuedHandler@call', 'data' => [ 'command' => 'O:32:"Illuminate\Tests\Queue\ExampleJob":0:{}', ], ]), 'exception' => 'Exception stack trace', 'failed_at' => '2026-05-18 12:00:00', ], ], ['--json' => true]); $this->assertJson($output); $this->assertJsonStringEqualsJsonString(json_encode([ [ 'id' => 'failed-job-id', 'connection' => 'redis', 'queue' => 'default', 'class' => 'Illuminate\Tests\Queue\ExampleJob', 'failed_at' => '2026-05-18 12:00:00', ], ]), $output); } protected function runCommandWithFailedJobs(array $failedJobs, array $arguments = []): string { $container = new Application; $failer = Mockery::mock(); $container->instance('queue.failer', $failer); $failer->expects('all')->andReturn($failedJobs); $command = new ListFailedCommand; $command->setLaravel($container); $output = new BufferedOutput; $command->run(new ArrayInput($arguments), $output); return $output->fetch(); } }