function ThemeInstallerTest::testInstallThemeWithMetModuleDependencies

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php \Drupal\KernelTests\Core\Theme\ThemeInstallerTest::testInstallThemeWithMetModuleDependencies()
  2. 10 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 202

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testInstallThemeWithMetModuleDependencies() {
    $name = 'test_theme_depending_on_modules';
    $themes = $this->themeHandler()
        ->listInfo();
    $this->assertArrayNotHasKey($name, $themes);
    $this->container
        ->get('module_installer')
        ->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->container
        ->get('module_installer')
        ->uninstall([
        'test_module_required_by_theme',
    ]);
}

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