public function FieldEncryptCacheTest::testDynamicPageCache in Field Encryption 8.2
Test caching of encrypted fields on response level.
File
- tests/
src/ Functional/ FieldEncryptCacheTest.php, line 47
Class
- FieldEncryptCacheTest
- Tests field encryption caching.
Namespace
Drupal\Tests\field_encrypt\FunctionalCode
public function testDynamicPageCache() {
// Page should be uncacheable due to max-age = 0.
$this
->drupalGet('node/' . $this->testNode
->id());
$this
->assertEquals('UNCACHEABLE', $this
->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Page with encrypted fields is uncacheable.');
// Set encrypted field as cacheable.
$this
->setFieldStorageSettings(TRUE, FALSE, FALSE);
// Page is cacheable, but currently not cached.
$this
->drupalGet('node/' . $this->testNode
->id());
$this
->assertEquals('MISS', $this
->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Dynamic Page Cache MISS.');
// Page is cacheable, and should be cached.
$this
->drupalGet('node/' . $this->testNode
->id());
$this
->assertEquals('HIT', $this
->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Dynamic Page Cache HIT.');
}