You are here

public function ChainRequestPolicyTest::testAllowIfAnyRuleReturnedAllow in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php \Drupal\Tests\Core\PageCache\ChainRequestPolicyTest::testAllowIfAnyRuleReturnedAllow()
  2. 9 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 105

Class

ChainRequestPolicyTest
@coversDefaultClass \Drupal\Core\PageCache\ChainRequestPolicy @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)
      ->will($this
      ->returnValue($return_value));
    $this->policy
      ->addPolicy($rule);
  }
  $actual_result = $this->policy
    ->check($this->request);
  $this
    ->assertSame(RequestPolicyInterface::ALLOW, $actual_result);
}