/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Queue/FailoverQueueTest.php
70 строк
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\Container\Container; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Queue\Attributes\Delay; use Illuminate\Queue\FailoverQueue; use Illuminate\Queue\QueueManager; use Mockery; use PHPUnit\Framework\TestCase; class FailoverQueueTest extends TestCase { protected function tearDown(): void { Container::setInstance(null); } public function test_push_fails_over_on_exception() { $queue = Mockery::mock(QueueManager::class); $events = Mockery::mock(Dispatcher::class); $failover = new FailoverQueue($queue, $events, [ 'redis', 'sync', ]); $redis = Mockery::mock('stdClass'); $queue->expects('connection')->with('redis')->andReturn($redis); $sync = Mockery::mock('stdClass'); $queue->expects('connection')->with('sync')->andReturn($sync); $events->expects('dispatch'); $redis->expects('push')->andReturnUsing( fn () => throw new \Exception('error') ); $sync->expects('push'); $failover->push('some-job'); } public function test_bulk_respects_job_delays() { $queue = Mockery::mock(QueueManager::class); $failover = new FailoverQueue($queue, Mockery::mock(Dispatcher::class), ['sync']); $sync = Mockery::mock('stdClass'); $queue->expects('connection')->times(3)->with('sync')->andReturn($sync); $sync->expects('later')->with(15, Mockery::type(FailoverJobWithDelayAttribute::class), '', null); $sync->expects('later')->with(30, Mockery::type(FailoverJobWithDelayProperty::class), '', null); $sync->expects('push')->with('regular-job', '', null); $failover->bulk([new FailoverJobWithDelayAttribute, new FailoverJobWithDelayProperty, 'regular-job']); } } #[Delay(15)] class FailoverJobWithDelayAttribute { } class FailoverJobWithDelayProperty { public $delay = 30; }