function ThemeTest::testUninstallingThemes in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/System/ThemeTest.php \Drupal\system\Tests\System\ThemeTest::testUninstallingThemes()
Test uninstalling of themes works.
File
- core/
modules/ system/ src/ Tests/ System/ ThemeTest.php, line 321 - Contains \Drupal\system\Tests\System\ThemeTest.
Class
- ThemeTest
- Tests the theme interface functionality by enabling and switching themes, and using an administration theme.
Namespace
Drupal\system\Tests\SystemCode
function testUninstallingThemes() {
// Install Bartik and set it as the default theme.
\Drupal::service('theme_handler')
->install(array(
'bartik',
));
// Set up seven as the admin theme.
\Drupal::service('theme_handler')
->install(array(
'seven',
));
$edit = array(
'admin_theme' => 'seven',
'use_admin_theme' => TRUE,
);
$this
->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
$this
->drupalGet('admin/appearance');
$this
->clickLink(t('Set as default'));
// Check that seven cannot be uninstalled as it is the admin theme.
$this
->assertNoRaw('Uninstall Seven theme', 'A link to uninstall the Seven theme does not appear on the theme settings page.');
// Check that bartik cannot be uninstalled as it is the default theme.
$this
->assertNoRaw('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does not appear on the theme settings page.');
// Check that the classy theme cannot be uninstalled as it is a base theme
// of seven and bartik.
$this
->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
// Install Stark and set it as the default theme.
\Drupal::service('theme_handler')
->install(array(
'stark',
));
$edit = array(
'admin_theme' => 'stark',
'use_admin_theme' => TRUE,
);
$this
->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
// Check that seven can be uninstalled now.
$this
->assertRaw('Uninstall Seven theme', 'A link to uninstall the Seven theme does appear on the theme settings page.');
// Check that the classy theme still cannot be uninstalled as it is a
// base theme of bartik.
$this
->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
// Change the default theme to stark, stark is second in the list.
$this
->clickLink(t('Set as default'), 1);
// Check that bartik can be uninstalled now.
$this
->assertRaw('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does appear on the theme settings page.');
// Check that the classy theme still can't be uninstalled as neither of it's
// base themes have been.
$this
->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
// Uninstall each of the three themes starting with Bartik.
$this
->clickLink(t('Uninstall'));
$this
->assertRaw('The <em class="placeholder">Bartik</em> theme has been uninstalled');
// Seven is the second in the list.
$this
->clickLink(t('Uninstall'));
$this
->assertRaw('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
->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
}