You are here

protected function AccessManagerTest::setupAccessArgumentsResolverFactory in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::setupAccessArgumentsResolverFactory()
  2. 10 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::setupAccessArgumentsResolverFactory()

Add default expectations to the access arguments resolver factory.

4 calls to AccessManagerTest::setupAccessArgumentsResolverFactory()
AccessManagerTest::testCheck in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests \Drupal\Core\Access\AccessManager::check().
AccessManagerTest::testCheckConjunctions in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Test \Drupal\Core\Access\AccessManager::check() with conjunctions.
AccessManagerTest::testCheckException in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests that an access checker throws an exception for not allowed values.
AccessManagerTest::testCheckNamedRoute in core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
Tests the checkNamedRoute method.

File

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

Class

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

Namespace

Drupal\Tests\Core\Access

Code

protected function setupAccessArgumentsResolverFactory($constraint = NULL) {
  if (!isset($constraint)) {
    $constraint = $this
      ->any();
  }
  return $this->argumentsResolverFactory
    ->expects($constraint)
    ->method('getArgumentsResolver')
    ->will($this
    ->returnCallback(function ($route_match, $account) {
    $resolver = $this
      ->createMock('Drupal\\Component\\Utility\\ArgumentsResolverInterface');
    $resolver
      ->expects($this
      ->any())
      ->method('getArguments')
      ->will($this
      ->returnCallback(function ($callable) use ($route_match) {
      return [
        $route_match
          ->getRouteObject(),
      ];
    }));
    return $resolver;
  }));
}