$route_2 =
new Route('test_route/example',
['_controller' => 'Drupal\Tests\Core\Controller\TestController'
]);
$collection->
add('test_route_2',
$route_2);
$route_event =
new RouteBuildEvent($collection);
[$display_1,
$display_2] =
$this->
setupMocks();
// The page_1 display overrides an existing route, so the dynamicRoutes
// should only call the second display.
$display_1->
expects($this->
once()) ->
method('collectRoutes'
) ->
willReturnCallback(function D
) use ($collection) { $collection->
add('views.test_id.page_1',
new Route('test_route',
['_controller' => 'Drupal\views\Routing\ViewPageController'
]));
return ['test_id.page_1' => 'views.test_id.page_1'
];
});
$display_1->
expects($this->
once()) ->
method('alterRoutes'
) ->
willReturn(['test_id.page_1' => 'test_route'
]);
$display_2->
expects($this->
once()) ->
method('collectRoutes'
) ->
willReturnCallback(function D
) use ($collection) { $collection->
add('views.test_id.page_2',
new Route('test_route',
['_controller' => 'Drupal\views\Routing\ViewPageController'
]));