You are here

public function BlockInterestCohortTest::testExistingInterestCohortPolicy in Drupal 9

Tests that an existing interest-cohort policy is not overwritten.

File

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

Class

BlockInterestCohortTest
Tests the Permissions-Policy header added by FinishResponseSubscriber.

Namespace

Drupal\KernelTests\Core\Http

Code

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