/** * @test */ public function queuePassesOptionsToQueue() { $mockOptions = ['foo' => 'Bar', 'baz' => 'Foos']; $job = new TestJob(); $this->jobManager->queue('TestQueue', $job, $mockOptions); $this->assertSame($mockOptions, $this->testQueue->getLastSubmitOptions()); }
/** * @param JoinPointInterface $joinPoint The current join point * @return mixed * @Flow\Around("methodAnnotatedWith(Flowpack\JobQueue\Common\Annotations\Defer)") */ public function queueMethodCallAsJob(JoinPointInterface $joinPoint) { if ($this->processingJob) { return $joinPoint->getAdviceChain()->proceed($joinPoint); } /** @var Defer $deferAnnotation */ $deferAnnotation = $this->reflectionService->getMethodAnnotation($joinPoint->getClassName(), $joinPoint->getMethodName(), Defer::class); $queueName = $deferAnnotation->queueName; $job = new StaticMethodCallJob($joinPoint->getClassName(), $joinPoint->getMethodName(), $joinPoint->getMethodArguments()); $this->jobManager->queue($queueName, $job, $deferAnnotation->options); return null; }
/** * @test */ public function waitAndExecuteEmitsMessageFailedSignal() { $this->jobManager->queue('TestQueue', new TestJob(1)); try { $this->jobManager->waitAndExecute('TestQueue'); } catch (JobQueueException $exception) { } $this->assertSignalEmitted('messageFailed', [$this->testQueue, new \PHPUnit_Framework_Constraint_IsInstanceOf(Message::class)]); }