function ThemeTest::testThemeSettingsRenderCacheClear

Same name in other branches
  1. 8.9.x 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 266

Class

ThemeTest
Tests the theme administration user interface.

Namespace

Drupal\Tests\system\Functional\System

Code

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

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