function ThemeTest::testUninstallingThemes
Same name in other branches
- 9 core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testUninstallingThemes()
- 8.9.x core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testUninstallingThemes()
- 11.x core/modules/system/tests/src/Functional/System/ThemeTest.php \Drupal\Tests\system\Functional\System\ThemeTest::testUninstallingThemes()
Tests uninstalling of themes works.
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ ThemeTest.php, line 480
Class
- ThemeTest
- Tests the theme administration user interface.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testUninstallingThemes() : void {
// Install olivero.
\Drupal::service('theme_installer')->install([
'olivero',
]);
// Set up Claro as the admin theme.
\Drupal::service('theme_installer')->install([
'claro',
]);
$edit = [
'admin_theme' => 'claro',
'use_admin_theme' => TRUE,
];
$this->drupalGet('admin/appearance');
$this->submitForm($edit, 'Save configuration');
// Set olivero as the default theme.
$this->cssSelect('a[title="Set Olivero as default theme"]')[0]
->click();
// Check that claro cannot be uninstalled as it is the admin theme.
$this->assertSession()
->responseNotContains('Uninstall claro theme');
// Check that olivero cannot be uninstalled as it is the default theme.
$this->assertSession()
->responseNotContains('Uninstall Olivero theme');
// Install Stark and set it as the default theme.
\Drupal::service('theme_installer')->install([
'stark',
]);
$edit = [
'admin_theme' => 'stark',
'use_admin_theme' => TRUE,
];
$this->drupalGet('admin/appearance');
$this->submitForm($edit, 'Save configuration');
// Check that claro can be uninstalled now.
$this->assertSession()
->responseContains('Uninstall claro theme');
// Change the default theme to stark, stark is second in the list.
$this->clickLink('Set as default', 1);
// Check that olivero can be uninstalled now.
$this->assertSession()
->responseContains('Uninstall Olivero theme');
// Uninstall each of the two themes starting with Olivero.
$this->cssSelect('a[title="Uninstall Olivero theme"]')[0]
->click();
$this->assertSession()
->responseContains('The <em class="placeholder">Olivero</em> theme has been uninstalled');
$this->cssSelect('a[title="Uninstall Claro theme"]')[0]
->click();
$this->assertSession()
->responseContains('The <em class="placeholder">Claro</em> theme has been uninstalled');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.