function ChainRequestPolicyTest::testAllowIfAnyRuleReturnedAllow

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php \Drupal\Tests\Core\PageCache\ChainRequestPolicyTest::testAllowIfAnyRuleReturnedAllow()
  2. 10 core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php \Drupal\Tests\Core\PageCache\ChainRequestPolicyTest::testAllowIfAnyRuleReturnedAllow()
  3. 11.x core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php \Drupal\Tests\Core\PageCache\ChainRequestPolicyTest::testAllowIfAnyRuleReturnedAllow()

Asserts that check() returns ALLOW if any of the rules returns ALLOW.

@dataProvider providerAllowIfAnyRuleReturnedAllow @covers ::check

File

core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php, line 108

Class

ChainRequestPolicyTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21PageCache%21ChainRequestPolicy.php/class/ChainRequestPolicy/9" title="Implements a compound request policy." class="local">\Drupal\Core\PageCache\ChainRequestPolicy</a> @group PageCache

Namespace

Drupal\Tests\Core\PageCache

Code

public function testAllowIfAnyRuleReturnedAllow($return_values) {
    foreach ($return_values as $return_value) {
        $rule = $this->createMock('Drupal\\Core\\PageCache\\RequestPolicyInterface');
        $rule->expects($this->once())
            ->method('check')
            ->with($this->request)
            ->willReturn($return_value);
        $this->policy
            ->addPolicy($rule);
    }
    $actual_result = $this->policy
        ->check($this->request);
    $this->assertSame(RequestPolicyInterface::ALLOW, $actual_result);
}

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