function ThemeTest::testThemeSettingsRenderCacheClear

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testThemeSettingsRenderCacheClear()
  2. 10 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testThemeSettingsRenderCacheClear()
  3. 11.x core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testThemeSettingsRenderCacheClear()

Tests the 'rendered' cache tag is cleared when saving theme settings.

File

core/modules/system/tests/src/Functional/System/ThemeTest.php, line 263

Class

ThemeTest
Tests the theme interface functionality by enabling and switching themes, and using an administration theme.

Namespace

Drupal\Tests\system\Functional\System

Code

public function testThemeSettingsRenderCacheClear() {
    $this->container
        ->get('theme_installer')
        ->install([
        'bartik',
    ]);
    // Ensure the frontpage is cached for anonymous users. The render cache will
    // cleared by installing a theme.
    $this->drupalLogout();
    $this->drupalGet('');
    $this->assertEquals('MISS', $this->getSession()
        ->getResponseHeader('X-Drupal-Cache'));
    $this->drupalGet('');
    $this->assertEquals('HIT', $this->getSession()
        ->getResponseHeader('X-Drupal-Cache'));
    $this->drupalLogin($this->adminUser);
    // Save Bartik's theme settings which should invalidate the 'rendered' cache
    // tag in \Drupal\system\EventSubscriber\ConfigCacheTag.
    $this->drupalPostForm('admin/appearance/settings/bartik', [], t('Save configuration'));
    $this->drupalLogout();
    $this->drupalGet('');
    $this->assertEquals('MISS', $this->getSession()
        ->getResponseHeader('X-Drupal-Cache'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.