function ChainResponsePolicyTest::testChainExceptionOnInvalidReturnValue

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php \Drupal\Tests\Core\PageCache\ChainResponsePolicyTest::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/ChainResponsePolicyTest.php, line 85

Class

ChainResponsePolicyTest
@coversDefaultClass \Drupal\Core\PageCache\ChainResponsePolicy[[api-linebreak]] @group PageCache

Namespace

Drupal\Tests\Core\PageCache

Code

public function testChainExceptionOnInvalidReturnValue($return_value) : void {
  $rule = $this->createMock('Drupal\\Core\\PageCache\\ResponsePolicyInterface');
  $rule->expects($this->once())
    ->method('check')
    ->with($this->response, $this->request)
    ->willReturn($return_value);
  $this->policy
    ->addPolicy($rule);
  $this->expectException(\UnexpectedValueException::class);
  $this->policy
    ->check($this->response, $this->request);
}

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