/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Queue/SkipIfBatchCancelledTest.php
74 строки
2 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Queue; use Illuminate\Bus\Batchable; use Illuminate\Bus\Dispatcher; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\Job; use Illuminate\Queue\CallQueuedHandler; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\SkipIfBatchCancelled; use Mockery; use Orchestra\Testbench\TestCase; class SkipIfBatchCancelledTest extends TestCase { public function testJobsAreSkippedOnceBatchIsCancelled() { [$beforeCancelled] = (new SkipCancelledBatchableTestJob())->withFakeBatch(); [$afterCancelled] = (new SkipCancelledBatchableTestJob())->withFakeBatch( cancelledAt: \Carbon\CarbonImmutable::now() ); $this->assertJobRanSuccessfully($beforeCancelled); $this->assertJobWasSkipped($afterCancelled); } protected function assertJobRanSuccessfully($class) { $this->assertJobHandled($class, true); } protected function assertJobWasSkipped($class) { $this->assertJobHandled($class, false); } protected function assertJobHandled($class, $expectedHandledValue) { $class::$handled = false; $instance = new CallQueuedHandler(new Dispatcher($this->app), $this->app); $job = Mockery::mock(Job::class); $job->expects('uuid')->andReturn('simple-test-uuid'); $job->expects('hasFailed')->andReturn(false); $job->shouldReceive('isReleased')->andReturn(false); $job->expects('isDeletedOrReleased')->andReturn(false); $job->expects('delete'); $instance->call($job, [ 'command' => serialize($command = $class), ]); $this->assertEquals($expectedHandledValue, $class::$handled); } } class SkipCancelledBatchableTestJob { use Batchable, InteractsWithQueue, Queueable; public static $handled = false; public function handle() { static::$handled = true; } public function middleware() { return [new SkipIfBatchCancelled]; } }