/** * @param \AMQPExchange|null $exchange * * @throws HectorException */ public function initialize(\AMQPExchange $exchange = null) { if (null == $exchange) { $exchange = new \AMQPExchange($this->channel->getWrappedChannel()); } $this->exchange = $exchange; $this->exchange->setName($this->getName()); $this->exchange->setType($this->context->getType()); $this->exchange->setArguments($this->context->getArguments()); $this->exchange->setFlags((int) $this->context->getFlags()); $this->exchange->declareExchange(); $this->initialized = true; }
public function it_should_initialize_exchange(Channel $channel, Context $context, \AMQPChannel $AMQPchannel, \AMQPExchange $AMQPExchange) { $channel->getWrappedChannel()->willReturn($AMQPchannel); $channel->getIdentity()->willReturn('channelID'); $context->getType()->willReturn('direct'); $context->getArguments()->willReturn(['foo' => 'bar']); $context->getFlags()->willReturn(1); $context->getType()->shouldBeCalled(); $context->getArguments()->shouldBeCalled(); $context->getFlags()->shouldBeCalled(); $this->beConstructedWith('exchange', $channel, $context); $this->initialize($AMQPExchange); $this->isInitialized()->shouldReturn(true); $this->getWrappedExchange()->shouldReturn($AMQPExchange); }