public function it_should_add_channel(Channel $a, Channel $b) { $a->getIdentity()->willReturn('a'); $b->getIdentity()->willReturn('b'); $this->addChannel($a); $this->addChannel($b); $this->getChannel('a')->shouldReturn($a); $this->getChannel('b')->shouldReturn($b); }
public function it_should_configure_connection(Connection $connection, Channel $channel, Exchange $exchange, Queue $queue) { $connection->connect()->shouldBeCalled(); $channel->isInitialized()->willReturn(false); $channel->initialize()->shouldBeCalled(); $exchange->isInitialized()->willReturn(false); $exchange->initialize()->shouldBeCalled(); $queue->isInitialized()->willReturn(false); $queue->initialize()->shouldBeCalled(); $this->initialize(); }
public function initialize() { $this->connection->connect(); if (false === $this->channel->isInitialized()) { $this->channel->initialize(); } if (false === $this->exchange->isInitialized()) { $this->exchange->initialize(); } if (false === $this->queue->isInitialized()) { $this->queue->initialize(); } $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); }
/** * @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_when_not_found(Channel $channel) { $channel->getIdentity()->willReturn('foo'); $this->shouldThrow(new NotFoundException('Unable to find exchange bar for channel foo'))->during('getExchange', ['bar', $channel]); }
/** * @param \Closure $closure * * @throws \Evaneos\Hector\Exception\HectorException * * @return bool */ public function transaction(\Closure $closure) { return $this->channel->transaction($closure); }
public function it_should_publish_message_with_routing_key_null(EventDispatcher $eventDispatcher, Exchange $exchange, Channel $channel, \AMQPExchange $AMQPExchange, Connection $connection, Identity $identity) { $message = 'foo.bar'; $routingKey = null; $flags = AMQP_NOPARAM; $attributes = ['x-expires' => 1000]; $event = new PublisherEvent($message, $routingKey, $flags, $attributes, $exchange->getWrappedObject()); $successEvent = new SuccessPublisherEvent($event); $connection->connect()->shouldBeCalled(); $channel->isInitialized()->willReturn(true); $exchange->isInitialized()->willReturn(true); $eventDispatcher->dispatch(PublisherEvents::PRE_PUBLISH, $event)->shouldBeCalled(); $AMQPExchange->publish($message, $routingKey, $flags, $attributes)->willReturn(true); $exchange->getWrappedExchange()->willReturn($AMQPExchange); $eventDispatcher->dispatch(PublisherEvents::SUCCESS_PUBLISH, $successEvent)->shouldBeCalled(); $this->publish($message, $routingKey, $flags, $attributes, false)->shouldReturn(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]); }
public function it_should_give_fingerprint(Channel $channel, Exchange $exchange) { $channel->getIdentity()->willReturn('channel'); $exchange->getName()->willReturn('exchange'); $this->getFingerPrint()->shouldReturn(sha1('channel' . 'exchange' . 'queue')); }
/** * @param string $name * @param Channel $channel * * @return bool */ public function isEqual($name, Channel $channel) { return sha1($channel->getIdentity() . $name) === $this->fingerPrint; }