Example #1
0
 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);
 }