public function VariantRouteFilterTest::testGetRequestAttributes in Page Manager 8
Same name and namespace in other branches
- 8.4 tests/src/Unit/VariantRouteFilterTest.php \Drupal\Tests\page_manager\Unit\VariantRouteFilterTest::testGetRequestAttributes()
@covers ::getRequestAttributes
File
- tests/
src/ Unit/ VariantRouteFilterTest.php, line 430 - 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 testGetRequestAttributes() {
$request = new Request();
$route = new Route('/path/with/{slug}');
$route_name = 'a_route';
$this->currentPath
->getPath($request)
->willReturn('/path/with/1');
$expected_attributes = [
'slug' => 1,
'_route_object' => $route,
'_route' => $route_name,
];
$route_enhancer = $this
->prophesize(RouteEnhancerInterface::class);
$route_enhancer
->enhance($expected_attributes, $request)
->willReturn([
'slug' => 'slug 1',
]);
$this->routeFilter
->addRouteEnhancer($route_enhancer
->reveal());
$this
->assertSame([], $request->attributes
->all());
$method = new \ReflectionMethod($this->routeFilter, 'getRequestAttributes');
$method
->setAccessible(TRUE);
$attributes = $method
->invoke($this->routeFilter, $route, $route_name, $request);
$this
->assertSame([
'slug' => 'slug 1',
], $attributes);
}