function AccessPolicyProcessorTest::setUpAccessPolicyProcessor

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php \Drupal\Tests\Core\Session\AccessPolicyProcessorTest::setUpAccessPolicyProcessor()

Sets up the access policy processor.

Return value

\Drupal\Core\Session\AccessPolicyProcessorInterface

13 calls to AccessPolicyProcessorTest::setUpAccessPolicyProcessor()
AccessPolicyProcessorTest::testAccountSwitcher in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
Tests if the account switcher switches properly when user cache context is present.
AccessPolicyProcessorTest::testAlterPermissions in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
Tests that access policies can alter the final result.
AccessPolicyProcessorTest::testAlterPermissionsNoApply in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
Tests that alters that do not apply are not processed.
AccessPolicyProcessorTest::testCacheContextCaching in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
Tests that the persistent cache contexts are added properly.
AccessPolicyProcessorTest::testCacheContexts in core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php
Tests that only the cache contexts for policies that apply are added.

... See full list

File

core/tests/Drupal/Tests/Core/Session/AccessPolicyProcessorTest.php, line 371

Class

AccessPolicyProcessorTest
Tests the AccessPolicyProcessor service.

Namespace

Drupal\Tests\Core\Session

Code

protected function setUpAccessPolicyProcessor(?VariationCacheInterface $variation_cache = NULL, ?VariationCacheInterface $variation_cache_static = NULL, ?CacheBackendInterface $cache_static = NULL, ?AccountProxyInterface $current_user = NULL, ?AccountSwitcherInterface $account_switcher = NULL) {
    // Prophecy does not accept a willReturn call on a mocked method if said
    // method has a return type of void. However, without willReturn() or any
    // other will* call, the method mock will not be registered.
    $prophecy_workaround = function () {
    };
    if (!isset($variation_cache)) {
        $variation_cache = $this->prophesize(VariationCacheInterface::class);
        $variation_cache->get(Argument::cetera())
            ->willReturn(FALSE);
        $variation_cache->set(Argument::cetera())
            ->will($prophecy_workaround);
        $variation_cache = $variation_cache->reveal();
    }
    if (!isset($variation_cache_static)) {
        $variation_cache_static = $this->prophesize(VariationCacheInterface::class);
        $variation_cache_static->get(Argument::cetera())
            ->willReturn(FALSE);
        $variation_cache_static->set(Argument::cetera())
            ->will($prophecy_workaround);
        $variation_cache_static = $variation_cache_static->reveal();
    }
    if (!isset($cache_static)) {
        $cache_static = $this->prophesize(CacheBackendInterface::class);
        $cache_static->get(Argument::cetera())
            ->willReturn(FALSE);
        $cache_static->set(Argument::cetera())
            ->will($prophecy_workaround);
        $cache_static = $cache_static->reveal();
    }
    if (!isset($current_user)) {
        $current_user = $this->prophesize(AccountProxyInterface::class)
            ->reveal();
    }
    if (!isset($account_switcher)) {
        $account_switcher = $this->prophesize(AccountSwitcherInterface::class)
            ->reveal();
    }
    return new AccessPolicyProcessor($variation_cache, $variation_cache_static, $cache_static, $current_user, $account_switcher);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.