You are here

public function AccessManagerTest::testSetChecks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testSetChecks()

Tests \Drupal\Core\Access\AccessManager::setChecks().

File

core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php, line 137
Contains \Drupal\Tests\Core\Access\AccessManagerTest.

Class

AccessManagerTest
@coversDefaultClass \Drupal\Core\Access\AccessManager @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testSetChecks() {

  // Check setChecks without any access checker defined yet.
  $this->checkProvider
    ->setChecks($this->routeCollection);
  foreach ($this->routeCollection
    ->all() as $route) {
    $this
      ->assertNull($route
      ->getOption('_access_checks'));
  }
  $this
    ->setupAccessChecker();
  $this->checkProvider
    ->setChecks($this->routeCollection);
  $this
    ->assertEquals($this->routeCollection
    ->get('test_route_1')
    ->getOption('_access_checks'), NULL);
  $this
    ->assertEquals($this->routeCollection
    ->get('test_route_2')
    ->getOption('_access_checks'), array(
    'test_access_default',
  ));
  $this
    ->assertEquals($this->routeCollection
    ->get('test_route_3')
    ->getOption('_access_checks'), array(
    'test_access_default',
  ));
}