protected function 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 drupal/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
Tests role requirements on routes.

File

drupal/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php, line 42
Contains \Drupal\Tests\Core\Route\RoleAccessCheckTest.

Class

RoleAccessCheckTest
Defines tests for role based access in routes.

Namespace

Drupal\Tests\Core\Route

Code

protected function getTestRouteCollection() {
  $route_collection = new RouteCollection();
  $route_collection
    ->add('role_test_1', new Route('/role_test_1', array(
    '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
  ), array(
    '_role' => 'role_test_1',
  )));
  $route_collection
    ->add('role_test_2', new Route('/role_test_2', array(
    '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
  ), array(
    '_role' => 'role_test_2',
  )));
  $route_collection
    ->add('role_test_3', new Route('/role_test_3', array(
    '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
  ), array(
    '_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', array(
    '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
  ), array(
    '_role' => 'role_test_1 + role_test_2',
  )));
  $route_collection
    ->add('role_test_5', new Route('/role_test_5', array(
    '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
  ), array(
    '_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', array(
    '_controller' => '\\Drupal\\router_test\\TestControllers::test1',
  ), array(
    '_role' => 'role_test_1 , role_test_2',
  )));
  return $route_collection;
}