Inheritance: extends Ddd\Infrastructure\Application\Notification\AmqpExchangeListener
 /** @test */
 public function itShouldListenForIncomingMessagesInAQueue()
 {
     if (!class_exists('AMQPConnection')) {
         $this->markTestSkipped('The AMQP extension is not available');
     }
     $queue = $this->prophesize('AMQPQueue');
     $serializer = SerializerBuilder::create()->setCacheDir(__DIR__ . '/../../../../var/cache/jms-serializer')->addMetadataDir(__DIR__ . '/../../../../src/Infrastructure/Application/Serialization/JMS/Config')->build();
     $storedEvent = new StoredEvent('Ddd\\Test\\Infrastructure\\Application\\Notification\\TestEvent', new DateTime(), $serializer->serialize(new TestEvent(), 'json'));
     $envelope = $this->prophesize('AMQPEnvelope');
     $envelope->getBody()->willReturn($serializer->serialize($storedEvent, 'json'));
     $revealedEnvelope = $envelope->reveal();
     $haveBeenCalled = false;
     $queue->get()->will(function () use($revealedEnvelope, &$haveBeenCalled) {
         if (false === $haveBeenCalled) {
             $haveBeenCalled = true;
             return $revealedEnvelope;
         }
         return false;
     });
     $loop = Factory::create();
     $listener = new TestListener($queue->reveal(), $loop, $serializer);
     sleep(1);
     $loop->tick();
     $this->assertCount(1, $listener->receivedEvents());
 }