/**
  * {@inheritdoc}
  */
 public function tick(Queue $queue, array $options = [])
 {
     // weired, no clue why this is necessary, but somehow configure is not invoked otherwise
     $this->doConfigure($options);
     if ($this->controller->doStop()) {
         return false;
     }
     if ($this->controller->doPause()) {
         return true;
     }
     return parent::tick($queue, $options);
 }
 /**
  * @test
  */
 public function it_sends_an_event_to_queue_pulls_it_with_consumer_and_forwards_it_to_event_bus()
 {
     $event = new SomethingDone(['data' => 'test event']);
     //The message dispatcher works with a ready-to-use bernard producer and one queue
     $messageProducer = new BernardMessageProducer($this->bernardProducer, 'test-queue');
     //Normally you would send the event on a event bus. We skip this step here cause we are only
     //interested in the function of the message dispatcher
     $messageProducer($event);
     //Set up event bus which will receive the event message from the bernard consumer
     $consumerEventBus = new EventBus();
     $somethingDoneListener = new MessageHandler();
     $consumerEventBus->utilize(new EventRouter([$event->messageName() => [$somethingDoneListener]]));
     //We use a special bernard router which forwards all messages to a command bus or event bus depending on the
     //Prooph\ServiceBus\Message\MessageHeader::TYPE
     $bernardRouter = new BernardRouter(new CommandBus(), $consumerEventBus);
     $bernardConsumer = new Consumer($bernardRouter, new EventDispatcher());
     //We use the same queue name here as we've defined for the message dispatcher above
     $bernardConsumer->tick($this->persistentFactory->create('test-queue'));
     $this->assertNotNull($somethingDoneListener->getLastMessage());
     $this->assertEquals($event->payload(), $somethingDoneListener->getLastMessage()->payload());
 }
 /**
  * @param TickOccurred $event
  */
 public function onTickOccurred(TickOccurred $event)
 {
     $this->psbBernardMessageConsumer->tick($this->queue);
 }