You are here

public function PurgeCacheTagsHeaderTest::testHeaderValue in Generic HTTP Purger 8

Test that the header value is exactly as expected (space separated).

File

modules/purge_purger_http_tagsheader/tests/src/Kernel/TagsHeader/PurgeCacheTagsHeaderTest.php, line 31

Class

PurgeCacheTagsHeaderTest
Tests \Drupal\purge_purger_http_tagsheader\Plugin\Purge\TagsHeader\PurgeCacheTagsHeader.

Namespace

Drupal\Tests\purge_purger_http\Kernel\TagsHeader

Code

public function testHeaderValue() : void {
  $request = Request::create('/system/401');
  $response = $this->container
    ->get('http_kernel')
    ->handle($request);
  $tags_header = $response->headers
    ->get('Purge-Cache-Tags');
  $tags = explode(' ', $tags_header);
  $this
    ->assertEquals(200, $response
    ->getStatusCode());
  $this
    ->assertTrue(is_string($tags_header));
  $this
    ->assertTrue(strlen($tags_header) > 5);
  $this
    ->assertTrue(in_array('config:user.role.anonymous', $tags));
  $this
    ->assertTrue(in_array('http_response', $tags));
  $this
    ->assertTrue(in_array('rendered', $tags));
}