setupAccessChecker example

/** * Tests \Drupal\Core\Access\AccessManager::setChecks(). */
  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'));
  }

  /** * Tests setChecks with a dynamic access checker. */
  
Home | Imprint | This part of the site doesn't use cookies.