function DisplayPageTest::testPageRouterItems
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testPageRouterItems()
- 10 core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testPageRouterItems()
- 11.x core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayPageTest::testPageRouterItems()
Checks that the router items are properly registered
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayPageTest.php, line 78
Class
- DisplayPageTest
- Tests the page display plugin.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testPageRouterItems() {
$collection = \Drupal::service('views.route_subscriber')->routes();
// Check the controller defaults.
foreach ($collection as $id => $route) {
$this->assertEqual($route->getDefault('_controller'), 'Drupal\\views\\Routing\\ViewPageController::handle');
$id_parts = explode('.', $id);
$this->assertEqual($route->getDefault('view_id'), $id_parts[1]);
$this->assertEqual($route->getDefault('display_id'), $id_parts[2]);
}
// Check the generated patterns and default values.
$route = $collection->get('view.test_page_display_route.page_1');
$this->assertEqual($route->getPath(), '/test_route_without_arguments');
$route = $collection->get('view.test_page_display_route.page_2');
$this->assertEqual($route->getPath(), '/test_route_with_argument/{arg_0}');
$this->assertTrue($route->hasDefault('arg_0'), 'A default value is set for the optional argument id.');
$route = $collection->get('view.test_page_display_route.page_3');
$this->assertEqual($route->getPath(), '/test_route_with_argument/{arg_0}/suffix');
$this->assertFalse($route->hasDefault('arg_0'), 'No default value is set for the required argument id.');
$route = $collection->get('view.test_page_display_route.page_4');
$this->assertEqual($route->getPath(), '/test_route_with_argument/{arg_0}/suffix/{arg_1}');
$this->assertFalse($route->hasDefault('arg_0'), 'No default value is set for the required argument id.');
$this->assertTrue($route->hasDefault('arg_1'), 'A default value is set for the optional argument id_2.');
$route = $collection->get('view.test_page_display_route.page_5');
$this->assertEqual($route->getPath(), '/test_route_with_argument/{arg_0}/{arg_1}');
$this->assertTrue($route->hasDefault('arg_0'), 'A default value is set for the optional argument id.');
$this->assertTrue($route->hasDefault('arg_1'), 'A default value is set for the optional argument id_2.');
$route = $collection->get('view.test_page_display_route.page_6');
$this->assertEqual($route->getPath(), '/test_route_with_argument/{arg_0}/{arg_1}');
$this->assertFalse($route->hasDefault('arg_0'), 'No default value is set for the required argument id.');
$this->assertFalse($route->hasDefault('arg_1'), 'No default value is set for the required argument id_2.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.