public function DisplayPageTest::testPageRouterItems in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Plugin/DisplayPageTest.php \Drupal\views\Tests\Plugin\DisplayPageTest::testPageRouterItems()
Checks that the router items are properly registered
File
- core/
modules/ views/ src/ Tests/ Plugin/ DisplayPageTest.php, line 91 - Contains \Drupal\views\Tests\Plugin\DisplayPageTest.
Class
- DisplayPageTest
- Tests the page display plugin.
Namespace
Drupal\views\Tests\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.');
}