Skip to content

Commit

Permalink
Allow older jobs to be faked (#48434)
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald authored Sep 18, 2023
1 parent 39bad03 commit d95209b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Testing/Fakes/QueueFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Support/SupportTestingQueueFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d95209b

Please sign in to comment.