You are here

public function AccessManagerTest::testSetChecks in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testSetChecks()
  2. 9 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 139
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
    ->assertNull($this->routeCollection
    ->get('test_route_1')
    ->getOption('_access_checks'));
  $this
    ->assertEquals([
    'test_access_default',
  ], $this->routeCollection
    ->get('test_route_2')
    ->getOption('_access_checks'));
  $this
    ->assertEquals([
    'test_access_default',
  ], $this->routeCollection
    ->get('test_route_3')
    ->getOption('_access_checks'));
}