Allow PHP-8.2 and up Compatibility instead of just PHP-8.4

This commit is contained in:
johnnyq
2026-06-12 17:06:10 -04:00
parent 2204bd52f4
commit d3a93652f3
220 changed files with 7198 additions and 2635 deletions

View File

@@ -2,11 +2,15 @@
namespace Illuminate\Support\Testing\Fakes;
use Closure;
use Illuminate\Bus\PendingBatch;
use Illuminate\Support\Collection;
use Illuminate\Support\Traits\ReflectsClosures;
class PendingBatchFake extends PendingBatch
{
use ReflectsClosures;
/**
* The fake bus instance.
*
@@ -23,7 +27,7 @@ class PendingBatchFake extends PendingBatch
public function __construct(BusFake $bus, Collection $jobs)
{
$this->bus = $bus;
$this->jobs = $jobs;
$this->jobs = $jobs->filter()->values();
}
/**
@@ -45,4 +49,39 @@ class PendingBatchFake extends PendingBatch
{
return $this->bus->recordPendingBatch($this);
}
/**
* Determine if the jobs in the batch match the given jobs.
*
* @param array $expectedJobs
* @return bool
*/
public function hasJobs(array $expectedJobs)
{
if (count($this->jobs) !== count($expectedJobs)) {
return false;
}
foreach ($expectedJobs as $index => $expectedJob) {
if ($expectedJob instanceof Closure) {
$expectedType = $this->firstClosureParameterType($expectedJob);
if (! $this->jobs[$index] instanceof $expectedType) {
return false;
}
if (! $expectedJob($this->jobs[$index])) {
return false;
}
} elseif (is_string($expectedJob)) {
if ($expectedJob != get_class($this->jobs[$index])) {
return false;
}
} elseif (serialize($expectedJob) != serialize($this->jobs[$index])) {
return false;
}
}
return true;
}
}