public function ThemeTest::testUninstallingThemes in Drupal 9
Same name and namespace in other branches
- 8 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 402
Class
- ThemeTest
- Tests the theme interface functionality by enabling and switching themes, and using an administration theme.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testUninstallingThemes() {
// Install Bartik and set it as the default theme.
\Drupal::service('theme_installer')
->install([
'bartik',
]);
// Set up seven as the admin theme.
\Drupal::service('theme_installer')
->install([
'seven',
]);
$edit = [
'admin_theme' => 'seven',
'use_admin_theme' => TRUE,
];
$this
->drupalGet('admin/appearance');
$this
->submitForm($edit, 'Save configuration');
$this
->drupalGet('admin/appearance');
$this
->clickLink('Set as default');
// Check that seven cannot be uninstalled as it is the admin theme.
$this
->assertSession()
->responseNotContains('Uninstall Seven theme');
// Check that bartik cannot be uninstalled as it is the default theme.
$this
->assertSession()
->responseNotContains('Uninstall Bartik theme');
// Check that the classy theme cannot be uninstalled as it is a base theme
// of seven and bartik.
$this
->assertSession()
->responseNotContains('Uninstall Classy 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 seven can be uninstalled now.
$this
->assertSession()
->responseContains('Uninstall Seven theme');
// Check that the classy theme still cannot be uninstalled as it is a
// base theme of bartik.
$this
->assertSession()
->responseNotContains('Uninstall Classy theme');
// Change the default theme to stark, stark is second in the list.
$this
->clickLink('Set as default', 1);
// Check that bartik can be uninstalled now.
$this
->assertSession()
->responseContains('Uninstall Bartik theme');
// Check that the classy theme still can't be uninstalled as neither of its
// base themes have been.
$this
->assertSession()
->responseNotContains('Uninstall Classy theme');
// Uninstall each of the three themes starting with Bartik.
$this
->clickLink('Uninstall');
$this
->assertSession()
->responseContains('The <em class="placeholder">Bartik</em> theme has been uninstalled');
// Seven is the second in the list.
$this
->clickLink('Uninstall');
$this
->assertSession()
->responseContains('The <em class="placeholder">Seven</em> theme has been uninstalled');
// Check that the classy theme still can't be uninstalled as it is hidden.
$this
->assertSession()
->responseNotContains('Uninstall Classy theme');
}