You are here

public function RouteProcessorManagerTest::testRouteProcessorManager in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php \Drupal\Tests\Core\RouteProcessor\RouteProcessorManagerTest::testRouteProcessorManager()

Tests the Route process manager functionality.

File

core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php, line 31

Class

RouteProcessorManagerTest
@coversDefaultClass \Drupal\Core\RouteProcessor\RouteProcessorManager @group RouteProcessor

Namespace

Drupal\Tests\Core\RouteProcessor

Code

public function testRouteProcessorManager() {
  $route = new Route('');
  $parameters = [
    'test' => 'test',
  ];
  $route_name = 'test_name';
  $processors = [
    10 => $this
      ->getMockProcessor($route_name, $route, $parameters),
    5 => $this
      ->getMockProcessor($route_name, $route, $parameters),
    0 => $this
      ->getMockProcessor($route_name, $route, $parameters),
  ];

  // Add the processors in reverse order.
  foreach ($processors as $priority => $processor) {
    $this->processorManager
      ->addOutbound($processor, $priority);
  }
  $bubbleable_metadata = new BubbleableMetadata();
  $this->processorManager
    ->processOutbound($route_name, $route, $parameters, $bubbleable_metadata);

  // Default cacheability is: permanently cacheable, no cache tags/contexts.
  $this
    ->assertEquals((new BubbleableMetadata())
    ->setCacheMaxAge(Cache::PERMANENT), $bubbleable_metadata);
}