public function VariantRouteFilterTest::testFilterAllowedAccess in Page Manager 8
Same name and namespace in other branches
- 8.4 tests/src/Unit/VariantRouteFilterTest.php \Drupal\Tests\page_manager\Unit\VariantRouteFilterTest::testFilterAllowedAccess()
@covers ::filter @covers ::getVariantRouteName @covers ::checkPageVariantAccess
File
- tests/
src/ Unit/ VariantRouteFilterTest.php, line 175 - Contains \Drupal\Tests\page_manager\Unit\VariantRouteFilterTest.
Class
- VariantRouteFilterTest
- @coversDefaultClass \Drupal\page_manager\Routing\VariantRouteFilter @group PageManager
Namespace
Drupal\Tests\page_manager\UnitCode
public function testFilterAllowedAccess() {
$route_collection = new RouteCollection();
$request = new Request();
$route = new Route('/path/with/{slug}', [
'page_manager_page_variant' => 'a_variant',
]);
$route_collection
->add('a_route', $route);
$page_variant = $this
->prophesize(PageVariantInterface::class);
$page_variant
->access('view')
->willReturn(TRUE);
$this->currentPath
->getPath($request)
->willReturn('');
$this->pageVariantStorage
->load('a_variant')
->willReturn($page_variant
->reveal());
$result = $this->routeFilter
->filter($route_collection, $request);
$expected = [
'a_route' => $route,
];
$this
->assertSame($expected, $result
->all());
$expected_attributes = [
'page_manager_page_variant' => 'a_variant',
'_route_object' => $route,
'_route' => 'a_route',
];
$this
->assertSame($expected_attributes, $request->attributes
->all());
}