/**
  * @covers Brickoo\Component\Routing\Route\Collector\MessageRouteCollector::collect
  * @covers Brickoo\Component\Routing\Route\Collector\MessageRouteCollector::extractRouteCollections
  */
 public function testRouteCollectorReturnsCollection()
 {
     $routeCollection = new RouteCollection();
     $messageDispatcher = new MessageDispatcher(new ListenerCollection(), new MessageRecursionDepthList());
     $messageDispatcher->attach(new RouteCollectorListenerFixture($routeCollection));
     $messageRouteCollector = new MessageRouteCollector($messageDispatcher);
     $this->assertInstanceOf("Brickoo\\Component\\Common\\Collection", $collection = $messageRouteCollector->collect());
     $this->assertSame($routeCollection, $collection->shift());
 }
 /**
  * Attach the listener for flushing messages.
  * @param MessageDispatcher $dispatcher
  * @return void
  */
 private function attachFlushMessageListener(MessageDispatcher $dispatcher)
 {
     $dispatcher->attach(new MessageListener(Messages::FLUSH, $this->listenerPriority, [$this, "handleFlushMessage"]));
 }
 /**
  * @covers Brickoo\Component\Messaging\MessageDispatcher::dispatch
  * @covers Brickoo\Component\Messaging\MessageDispatcher::processMessage
  * @covers Brickoo\Component\Messaging\Exception\MaxRecursionDepthReachedException
  * @expectedException \Brickoo\Component\Messaging\Exception\MaxRecursionDepthReachedException
  */
 public function testProcessRecursionDepthLimitIsDetected()
 {
     $messageDispatcher = new MessageDispatcher(new ListenerCollection(), new MessageRecursionDepthList());
     $messageDispatcher->attach(new MessageListenerInfiniteRecursionFixture());
     $message = new GenericMessage("message.test");
     $this->assertSame($messageDispatcher, $messageDispatcher->dispatch($message));
     $messageDispatcher->dispatch($message);
 }
 public function attachListeners(MessageDispatcher $messageManager)
 {
     $messageManager->attach(new MessageListener("test.message", 100, [$this, "listenerCallback"]));
 }