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