/** * */ public function setUp() { // $this->jobManager = new JobManager(); $this->jobManager = $this->getMock(JobManager::class, array('__destruct'), array(), '', false); $this->testQueue = new MemoryQueue($this->queueName, []); $this->queueManager = $this->getMock(QueueManager::class, array('getQueue', 'getQueues'), array(), '', false); $this->queueManager->expects($this->any())->method('getQueue')->with($this->queueName)->will($this->returnValue($this->testQueue)); $this->queueManager->expects($this->any())->method('getQueues')->will($this->returnValue(array())); $this->inject($this->jobManager, 'queueManager', $this->queueManager); $worker = $this->getMock(Worker::class, array('work'), array(), '', false); $this->inject($this->jobManager, 'worker', $this->worker); $this->extensionConfiguration = $this->getMock(ExtensionConfiguration::class, array('get'), array(), '', false); $this->inject($this->jobManager, 'extensionConfiguration', $this->extensionConfiguration); $this->failedJobRepository = $this->getMock(FailedJobRepository::class, array('add'), array(), '', false); $this->inject($this->jobManager, 'failedJobRepository', $this->failedJobRepository); $signalSlotDispatcher = $this->getMock(Dispatcher::class, array('dispatch'), array(), '', false); $this->inject($this->jobManager, 'signalSlotDispatcher', $signalSlotDispatcher); }
/** * Flush all memory queues. * * @return void */ protected function flushMemoryQueues() { $queues = $this->queueManager->getQueues(); foreach ($queues as $queue) { if ($queue instanceof \R3H6\Jobqueue\Queue\MemoryQueue) { $this->worker->work($queue->getName(), 0, Worker::LIMIT_QUEUE); } } }