/** * {@inheritDoc} */ public function enqueue(JobInterface $job) { $this->eventDispatcher->dispatch(ResqueQueueEvents::JOB_PUSH, new QueueJobEvent($this, $job)); if ($this->storage->enqueue($this, $job)) { $this->eventDispatcher->dispatch(ResqueQueueEvents::JOB_PUSHED, new QueueJobEvent($this, $job)); return true; } return false; }
function it_does_not_emit_pushed_if_storage_fails(QueueStorageInterface $storage, EventDispatcherInterface $eventDispatcher, JobInterface $job) { $eventDispatcher->dispatch(ResqueQueueEvents::JOB_PUSH, Argument::type('Resque\\Component\\Queue\\Event\\QueueJobEvent'))->shouldBeCalled(); $storage->enqueue($this, $job)->shouldBeCalled()->willReturn(false); $eventDispatcher->dispatch(ResqueQueueEvents::JOB_PUSHED, Argument::type('Resque\\Component\\Queue\\Event\\QueueJobEvent'))->shouldNotBeCalled(); $this->enqueue($job)->shouldReturn(false); }