function ChainRequestPolicyTest::testChainExceptionOnInvalidReturnValue

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

Asserts that check() throws an exception if a rule returns an invalid value.

@dataProvider providerChainExceptionOnInvalidReturnValue @covers ::check

File

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

Class

ChainRequestPolicyTest
@coversDefaultClass \Drupal\Core\PageCache\ChainRequestPolicy @group PageCache

Namespace

Drupal\Tests\Core\PageCache

Code

public function testChainExceptionOnInvalidReturnValue($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);
    $this->expectException(\UnexpectedValueException::class);
    $this->policy
        ->check($this->request);
}

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