function ThemeInstallerTest::testInstallThemeWithMetModuleDependencies

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest::testInstallThemeWithMetModuleDependencies()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest::testInstallThemeWithMetModuleDependencies()
  3. 11.x core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest::testInstallThemeWithMetModuleDependencies()

Tests installing a theme with module dependencies that are met.

File

core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php, line 245

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testInstallThemeWithMetModuleDependencies() : void {
    $name = 'test_theme_depending_on_modules';
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertArrayNotHasKey($name, $themes);
    $this->moduleInstaller()
        ->install([
        'test_module_required_by_theme',
        'test_another_module_required_by_theme',
    ]);
    $this->themeInstaller()
        ->install([
        $name,
    ]);
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertArrayHasKey($name, $themes);
    $this->expectException(ModuleUninstallValidatorException::class);
    $this->expectExceptionMessage('The following reasons prevent the modules from being uninstalled: Required by the theme: Test Theme Depending on Modules');
    $this->moduleInstaller()
        ->uninstall([
        'test_module_required_by_theme',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.