You are here

public function BlockInterestCohortTest::testExistingPolicyHeader in Drupal 10

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php \Drupal\KernelTests\Core\Http\BlockInterestCohortTest::testExistingPolicyHeader()

Tests that an existing header is not modified.

File

core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php, line 47

Class

BlockInterestCohortTest
Tests the Permissions-Policy header added by FinishResponseSubscriber.

Namespace

Drupal\KernelTests\Core\Http

Code

public function testExistingPolicyHeader() {
  $headers['Permissions-Policy'] = 'geolocation=()';
  $kernel = \Drupal::service('http_kernel');
  $request = Request::create('/');
  $response = new Response('', 200, $headers);
  $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response);
  \Drupal::service('finish_response_subscriber')
    ->onRespond($event);
  $this
    ->assertSame($headers['Permissions-Policy'], $response->headers
    ->get('Permissions-Policy'));
}