mirror of
https://github.com/itflow-org/itflow
synced 2026-06-20 00:31:05 +00:00
Allow PHP-8.2 and up Compatibility instead of just PHP-8.4
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user