public function it_should_initialize(\AMQPQueue $queue, Exchange $exchange, Context $context) { $exchange->getName()->willReturn('exchange'); $context->getFlags()->willReturn(1234); $context->getArguments()->willReturn(['foo' => 'bar']); $queue->setName('queue')->shouldBeCalled(); $queue->bind('exchange')->shouldBeCalled(); $queue->setFlags(1234)->shouldBeCalled(); $queue->setArguments(['foo' => 'bar'])->shouldBeCalled(); $queue->declareQueue()->shouldBeCalled(); $this->initialize($queue); $this->isInitialized()->shouldReturn(true); }
/** * @param \AMQPQueue|null $queue * * @throws HectorException */ public function initialize(\AMQPQueue $queue = null) { if (true === $this->isInitialized()) { throw new HectorException('Queue already initialized'); } if (null === $queue) { $queue = new \AMQPQueue($this->channel->getWrappedChannel()); } $this->queue = $queue; $this->queue->setName($this->getName()); $this->queue->bind($this->exchange->getName()); $this->queue->setFlags($this->context->getFlags()); $this->queue->setArguments($this->context->getArguments()); $this->queue->declareQueue(); $this->initialized = true; }
public function it_should_throw_exception_if_no_queue(Channel $channel, Exchange $exchange) { $channel->getIdentity()->willReturn('bar'); $exchange->getName()->willReturn('baz'); $this->shouldThrow(new NotFoundException('Unable to find queue foo for channel bar and exchange baz'))->during('getQueue', ['foo', $channel, $exchange]); }