Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 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]);
 }
Example #4
0
 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]);
 }
Example #5
0
 /**
  * @param string   $name
  * @param Channel  $channel
  * @param Exchange $exchange
  *
  * @return string
  */
 private function computeFingerPrint($name, Channel $channel, Exchange $exchange)
 {
     return sha1($channel->getIdentity() . $exchange->getName() . $name);
 }
Example #6
0
 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'));
 }
Example #7
0
 /**
  * @param string  $name
  * @param Channel $channel
  *
  * @return bool
  */
 public function isEqual($name, Channel $channel)
 {
     return sha1($channel->getIdentity() . $name) === $this->fingerPrint;
 }