function ViewPageControllerTest::testHandleWithArgumentsOnOverriddenRoute
Same name in other branches
- 8.9.x core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php \Drupal\Tests\views\Unit\Routing\ViewPageControllerTest::testHandleWithArgumentsOnOverriddenRoute()
- 10 core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php \Drupal\Tests\views\Unit\Routing\ViewPageControllerTest::testHandleWithArgumentsOnOverriddenRoute()
- 11.x core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php \Drupal\Tests\views\Unit\Routing\ViewPageControllerTest::testHandleWithArgumentsOnOverriddenRoute()
Tests the page controller with arguments of an overridden page view.
Note: This test does not care about upcasting for now.
File
-
core/
modules/ views/ tests/ src/ Unit/ Routing/ ViewPageControllerTest.php, line 111
Class
- ViewPageControllerTest
- @coversDefaultClass \Drupal\views\Routing\ViewPageController @group views
Namespace
Drupal\Tests\views\Unit\RoutingCode
public function testHandleWithArgumentsOnOverriddenRoute() {
$request = new Request();
$request->attributes
->set('view_id', 'test_page_view');
$request->attributes
->set('display_id', 'page_1');
// Add the argument to the request.
$request->attributes
->set('parameter', 'test-argument');
$options = [
'_view_argument_map' => [
'arg_0' => 'parameter',
],
'_view_display_plugin_class' => '\\Drupal\\views\\Plugin\\views\\display\\Page',
];
$request->attributes
->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test/{parameter}', [
'view_id' => 'test_page_view',
'display_id' => 'default',
], [], $options));
$route_match = RouteMatch::createFromRequest($request);
$result = $this->pageController
->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match);
$build = [
'#type' => 'view',
'#name' => 'test_page_view',
'#display_id' => 'page_1',
'#embed' => FALSE,
'#arguments' => [
'test-argument',
],
'#cache' => [
'keys' => [
'view',
'test_page_view',
'display',
'page_1',
'args',
'test-argument',
],
],
] + $this->defaultRenderArray;
$this->assertEquals($build, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.