/** * Push a job by its name onto the selected queue * * @param string $name Name of the job to create * @param mixed $payload Payload of the job set as content * @throws QueueNotFoundException If the method is called without a queue set * @return JobInterface Created job by the job plugin manager */ public function push($name, $payload = null) { if (null === $this->queue) { throw new QueueNotFoundException('You cannot push a job without a queue selected'); } $job = $this->jobPluginManager->get($name); if (null !== $payload) { $job->setContent($payload); } return $this->queue->push($job); }
public function testPluginManagerThrowsExceptionOnInvalidJobClasses() { $jobPluginManager = new JobPluginManager(); $jobPluginManager->setInvokableClass('InvalidJob', 'stdClass'); $this->setExpectedException('SlmQueue\\Job\\Exception\\RuntimeException'); $instance = $jobPluginManager->get('InvalidJob'); }