public function testAdd() { $command = new Command(); $queue = 'test-queue'; $this->driver->expects($this->once())->method('enqueue')->with($queue, $command)->willReturn(true); $this->assertTrue($this->queue->add($queue, $command)); }
/** * Handles fetching messages from the queue * * @param string $queue * * @return bool */ protected function tick($queue) { if ($this->shutdown) { $this->event->shutdown(); return false; } list($command, $job) = $this->driver->dequeue($queue); if (empty($command) && $this->drain) { $this->event->drained(); return false; } elseif (empty($command)) { return true; } try { $this->event->acknowledge($command); $this->command_bus->handle($command); $this->event->finish($command); } catch (Exception $exception) { $this->queue->add(sprintf('%s-failed', $queue), $command); $this->event->reject($command, $exception); } finally { $this->driver->processed($job); } return true; }
/** * Add a message to the queue * * @param string $queue * @param string $command * * @return bool */ public function add($queue, $command) { return $this->driver->enqueue($queue, $command); }