function RoleAccessCheckTest::getTestRouteCollection

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php \Drupal\Tests\Core\Route\RoleAccessCheckTest::getTestRouteCollection()
  2. 8.9.x core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php \Drupal\Tests\Core\Route\RoleAccessCheckTest::getTestRouteCollection()
  3. 10 core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php \Drupal\Tests\Core\Route\RoleAccessCheckTest::getTestRouteCollection()

Generates the test route collection.

Return value

\Symfony\Component\Routing\RouteCollection Returns the test route collection.

1 call to RoleAccessCheckTest::getTestRouteCollection()
RoleAccessCheckTest::testRoleAccess in core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
Tests role requirements on routes.

File

core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php, line 29

Class

RoleAccessCheckTest
@coversDefaultClass \Drupal\user\Access\RoleAccessCheck @group Access @group Route

Namespace

Drupal\Tests\Core\Route

Code

protected function getTestRouteCollection() {
    $route_collection = new RouteCollection();
    $route_collection->add('role_test_1', new Route('/role_test_1', [
        '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
    ], [
        '_role' => 'role_test_1',
    ]));
    $route_collection->add('role_test_2', new Route('/role_test_2', [
        '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
    ], [
        '_role' => 'role_test_2',
    ]));
    $route_collection->add('role_test_3', new Route('/role_test_3', [
        '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
    ], [
        '_role' => 'role_test_1,role_test_2',
    ]));
    // Ensure that trimming the values works on "OR" conjunctions.
    $route_collection->add('role_test_4', new Route('/role_test_4', [
        '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
    ], [
        '_role' => 'role_test_1 , role_test_2',
    ]));
    $route_collection->add('role_test_5', new Route('/role_test_5', [
        '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
    ], [
        '_role' => 'role_test_1+role_test_2',
    ]));
    // Ensure that trimming the values works on "AND" conjunctions.
    $route_collection->add('role_test_6', new Route('/role_test_6', [
        '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
    ], [
        '_role' => 'role_test_1 + role_test_2',
    ]));
    return $route_collection;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.