You are here

public function AccessManagerTest::testCheckConjunctions 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::testCheckConjunctions()

Test \Drupal\Core\Access\AccessManager::check() with conjunctions.

@dataProvider providerTestCheckConjunctions

File

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

Class

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

Namespace

Drupal\Tests\Core\Access

Code

public function testCheckConjunctions($name, $condition_one, $condition_two, $expected_access) {
  $this
    ->setupAccessChecker();
  $access_check = new DefinedTestAccessCheck();
  $this->container
    ->register('test_access_defined', $access_check);
  $this->checkProvider
    ->addCheckService('test_access_defined', 'access', array(
    '_test_access',
  ));
  $route_collection = new RouteCollection();

  // Setup a test route for each access configuration.
  $requirements = array(
    '_access' => $condition_one,
    '_test_access' => $condition_two,
  );
  $route = new Route($name, array(), $requirements);
  $route_collection
    ->add($name, $route);
  $this->checkProvider
    ->setChecks($route_collection);
  $this
    ->setupAccessArgumentsResolverFactory();
  $route_match = new RouteMatch($name, $route, array(), array());
  $this
    ->assertEquals($expected_access
    ->isAllowed(), $this->accessManager
    ->check($route_match, $this->account));
  $this
    ->assertEquals($expected_access, $this->accessManager
    ->check($route_match, $this->account, NULL, TRUE));
}