RouteProcessorManagerTest.php in Zircon Profile 8.0
File
core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php
View source
<?php
namespace Drupal\Tests\Core\RouteProcessor;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\RouteProcessor\RouteProcessorManager;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Routing\Route;
class RouteProcessorManagerTest extends UnitTestCase {
protected $processorManager;
protected function setUp() {
$this->processorManager = new RouteProcessorManager();
}
public function testRouteProcessorManager() {
$route = new Route('');
$parameters = array(
'test' => 'test',
);
$route_name = 'test_name';
$processors = array(
10 => $this
->getMockProcessor($route_name, $route, $parameters),
5 => $this
->getMockProcessor($route_name, $route, $parameters),
0 => $this
->getMockProcessor($route_name, $route, $parameters),
);
foreach ($processors as $priority => $processor) {
$this->processorManager
->addOutbound($processor, $priority);
}
$bubbleable_metadata = new BubbleableMetadata();
$this->processorManager
->processOutbound($route_name, $route, $parameters, $bubbleable_metadata);
$this
->assertEquals((new BubbleableMetadata())
->setCacheMaxAge(Cache::PERMANENT), $bubbleable_metadata);
}
protected function getMockProcessor($route_name, $route, $parameters) {
$processor = $this
->getMock('Drupal\\Core\\RouteProcessor\\OutboundRouteProcessorInterface');
$processor
->expects($this
->once())
->method('processOutbound')
->with($route_name, $route, $parameters);
return $processor;
}
}