function ThemeTest::testThemeSettingsRenderCacheClear

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testThemeSettingsRenderCacheClear()
  2. 8.9.x core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testThemeSettingsRenderCacheClear()
  3. 10 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 322

Class

ThemeTest
Tests the theme administration user interface.

Namespace

Drupal\Tests\system\Functional\System

Code

public function testThemeSettingsRenderCacheClear() : void {
    $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.