You are here

public function ThemeInstallerTest::testInstallThemeWithMetModuleDependencies in Drupal 8

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()

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',
  ]);
}