Skip to content

Commit

Permalink
Allow older jobs to be faked
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Sep 18, 2023
1 parent f0d949b commit 1ee2ade
Show file tree
Hide file tree
Showing 2 changed files with 12 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
11 changes: 11 additions & 0 deletions tests/Support/SupportTestingQueueFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ public function testItCanSerializeAndRestoreJobs()
fn ($job) => $job->value === 'hello-serialized-unserialized'
);
}

public function testItCanFakePushedJobsWithClassAndPayload()
{
$fake = new QueueFake(new Application, ['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 1ee2ade

Please sign in to comment.