From d95209b32e4f7516b05d046ea100fd4aaddef864 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Tue, 19 Sep 2023 00:50:36 +1000 Subject: [PATCH] Allow older jobs to be faked (#48434) --- src/Illuminate/Support/Testing/Fakes/QueueFake.php | 2 +- tests/Support/SupportTestingQueueFakeTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Testing/Fakes/QueueFake.php b/src/Illuminate/Support/Testing/Fakes/QueueFake.php index aa63e2e10c18..032136089174 100644 --- a/src/Illuminate/Support/Testing/Fakes/QueueFake.php +++ b/src/Illuminate/Support/Testing/Fakes/QueueFake.php @@ -387,7 +387,7 @@ public function shouldFakeJob($job) } return $this->jobsToFake->contains( - fn ($jobToFake) => $job instanceof ((string) $jobToFake) + fn ($jobToFake) => $job instanceof ((string) $jobToFake) || $job === (string) $jobToFake ); } diff --git a/tests/Support/SupportTestingQueueFakeTest.php b/tests/Support/SupportTestingQueueFakeTest.php index b0754387c562..e10f83ff1f8d 100644 --- a/tests/Support/SupportTestingQueueFakeTest.php +++ b/tests/Support/SupportTestingQueueFakeTest.php @@ -392,6 +392,19 @@ public function testItCanSerializeAndRestoreJobs() fn ($job) => $job->value === 'hello-serialized-unserialized' ); } + + public function testItCanFakePushedJobsWithClassAndPayload() + { + $fake = new QueueFake(new Application, ['JobStub']); + + $this->assertTrue($fake->shouldFakeJob('JobStub')); + + $fake->push('JobStub', ['job' => 'payload']); + + $fake->assertPushed('JobStub'); + $fake->assertPushed('JobStub', 1); + $fake->assertPushed('JobStub', fn ($job, $queue, $payload) => $payload === ['job' => 'payload']); + } } class JobStub