diff --git a/src/Tests/TagsHeader/CacheableResponseSubscriberTest.php b/src/Tests/TagsHeader/CacheableResponseSubscriberTest.php deleted file mode 100644 index 271eec9..0000000 --- a/src/Tests/TagsHeader/CacheableResponseSubscriberTest.php +++ /dev/null @@ -1,64 +0,0 @@ -container->get('http_kernel')->handle($request); - $this->assertEqual(200, $response->getStatusCode()); - $header = $response->headers->get($header_name); - $this->assertNotNull($header, "$header_name header exists."); - $this->assertTrue(is_string($header)); - $this->assertTrue(strpos($header, 'config:user.role.anonymous') !== FALSE); - $this->assertTrue(strpos($header, 'rendered') !== FALSE); - } - - /** - * {@inheritdoc} - */ - function setUp() { - parent::setUp(); - $this->installSchema('system', ['router']); - \Drupal::service('router.builder')->rebuild(); - } - - /** - * Test header presence. - */ - public function testHeaderPresence() { - $this->assertCacheTagsHeader('/system/401', 'Purge-Cache-Tags'); - $this->assertCacheTagsHeader('/system/401', 'Header-A'); - $this->assertCacheTagsHeader('/system/401', 'Header-B'); - $this->assertCacheTagsHeader('/system/401', 'Header-C'); - } - -} diff --git a/src/Tests/TagsHeader/PurgeCacheTagsHeaderTest.php b/src/Tests/TagsHeader/PurgeCacheTagsHeaderTest.php deleted file mode 100644 index 890603b..0000000 --- a/src/Tests/TagsHeader/PurgeCacheTagsHeaderTest.php +++ /dev/null @@ -1,45 +0,0 @@ -installSchema('system', ['router']); - \Drupal::service('router.builder')->rebuild(); - } - - /** - * Test that the header value is exactly as expected (space separated). - */ - public function testHeaderValue() { - $request = Request::create('/system/401'); - $response = $this->container->get('http_kernel')->handle($request); - $this->assertEqual(200, $response->getStatusCode()); - $this->assertEqual($response->headers->get('Purge-Cache-Tags'), 'config:user.role.anonymous rendered'); - } - -} diff --git a/tests/src/Unit/TagsHeader/CacheableResponseSubscriberTest.php b/tests/src/Unit/TagsHeader/CacheableResponseSubscriberTest.php new file mode 100644 index 0000000..356593f --- /dev/null +++ b/tests/src/Unit/TagsHeader/CacheableResponseSubscriberTest.php @@ -0,0 +1,59 @@ +container->get('http_kernel')->handle($request); + $this->assertEquals(200, $response->getStatusCode()); + $header = $response->headers->get($header_name); + $this->assertNotNull($header, "$header_name header exists."); + $this->assertTrue(is_string($header)); + $this->assertTrue(strpos($header, 'config:user.role.anonymous') !== FALSE); + $this->assertTrue(strpos($header, 'rendered') !== FALSE); + } + + /** + * {@inheritdoc} + */ + function setUp($switch_to_memory_queue = TRUE) { + parent::setUp($switch_to_memory_queue); + $this->installSchema('system', ['router']); + \Drupal::service('router.builder')->rebuild(); + } + + /** + * Test header presence. + */ + public function testHeaderPresence() { + $this->assertCacheTagsHeader('/system/401', 'Purge-Cache-Tags'); + $this->assertCacheTagsHeader('/system/401', 'Header-A'); + $this->assertCacheTagsHeader('/system/401', 'Header-B'); + $this->assertCacheTagsHeader('/system/401', 'Header-C'); + } + +} diff --git a/tests/src/Unit/TagsHeader/PurgeCacheTagsHeaderTest.php b/tests/src/Unit/TagsHeader/PurgeCacheTagsHeaderTest.php new file mode 100644 index 0000000..dfa797a --- /dev/null +++ b/tests/src/Unit/TagsHeader/PurgeCacheTagsHeaderTest.php @@ -0,0 +1,40 @@ +installSchema('system', ['router']); + \Drupal::service('router.builder')->rebuild(); + } + + /** + * Test that the header value is exactly as expected (space separated). + */ + public function testHeaderValue() { + $request = Request::create('/system/401'); + $response = $this->container->get('http_kernel')->handle($request); + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals($response->headers->get('Purge-Cache-Tags'), 'config:user.role.anonymous rendered'); + } + +}