You are here

protected function RoleAccessCheckTest::getTestRouteCollection in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 32
Contains \Drupal\Tests\Core\Route\RoleAccessCheckTest.

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', 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;
}