mirror of
https://github.com/itflow-org/itflow
synced 2026-06-16 14:51:04 +00:00
Allow PHP-8.2 and up Compatibility instead of just PHP-8.4
This commit is contained in:
@@ -4,7 +4,10 @@ namespace Illuminate\Support\Testing\Fakes;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Closure;
|
||||
use Illuminate\Bus\UniqueLock;
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Contracts\Queue\Queue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Events\CallQueuedListener;
|
||||
use Illuminate\Queue\CallQueuedClosure;
|
||||
use Illuminate\Queue\QueueManager;
|
||||
@@ -55,6 +58,13 @@ class QueueFake extends QueueManager implements Fake, Queue
|
||||
*/
|
||||
protected $rawPushes = [];
|
||||
|
||||
/**
|
||||
* All of the unique jobs that were pushed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $uniqueJobs = [];
|
||||
|
||||
/**
|
||||
* Indicates if items should be serialized and restored when pushed to the queue.
|
||||
*
|
||||
@@ -121,7 +131,7 @@ class QueueFake extends QueueManager implements Fake, Queue
|
||||
* @param int $times
|
||||
* @return void
|
||||
*/
|
||||
protected function assertPushedTimes($job, $times = 1)
|
||||
public function assertPushedTimes($job, $times = 1)
|
||||
{
|
||||
$count = $this->pushed($job)->count();
|
||||
|
||||
@@ -477,6 +487,10 @@ class QueueFake extends QueueManager implements Fake, Queue
|
||||
'queue' => $queue,
|
||||
'data' => $data,
|
||||
];
|
||||
|
||||
if ($job instanceof ShouldBeUnique) {
|
||||
$this->uniqueJobs[] = $job;
|
||||
}
|
||||
} else {
|
||||
is_object($job) && isset($job->connection)
|
||||
? $this->queue->connection($job->connection)->push($job, $data, $queue)
|
||||
@@ -650,6 +664,22 @@ class QueueFake extends QueueManager implements Fake, Queue
|
||||
return unserialize(serialize($job));
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the locks for all unique jobs that were pushed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function releaseUniqueJobLocks()
|
||||
{
|
||||
$lock = new UniqueLock($this->app->make(Cache::class));
|
||||
|
||||
foreach ($this->uniqueJobs as $job) {
|
||||
$lock->release($job);
|
||||
}
|
||||
|
||||
$this->uniqueJobs = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connection name for the queue.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user