You are here

public function ModuleRequiredByThemesUninstallValidatorTest::testValidateOneThemeDependency in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php \Drupal\Tests\Core\Extension\ModuleRequiredByThemesUninstallValidatorTest::testValidateOneThemeDependency()

@covers ::validate

File

core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php, line 71

Class

ModuleRequiredByThemesUninstallValidatorTest
@coversDefaultClass \Drupal\Core\Extension\ModuleRequiredByThemesUninstallValidator @group Extension

Namespace

Drupal\Tests\Core\Extension

Code

public function testValidateOneThemeDependency() {
  $module = 'single_module';
  $module_name = 'Single Module';
  $theme = 'one_theme';
  $theme_name = 'One Theme';
  $this->themeExtensionList
    ->getAllInstalledInfo()
    ->willReturn([
    'stable' => [
      'name' => 'Stable',
      'dependencies' => [],
    ],
    'claro' => [
      'name' => 'Claro',
      'dependencies' => [],
    ],
    $theme => [
      'name' => $theme_name,
      'dependencies' => [
        $module,
      ],
    ],
  ]);
  $this->moduleExtensionList
    ->get($module)
    ->willReturn((object) [
    'info' => [
      'name' => $module_name,
    ],
  ]);
  $expected = [
    "Required by the theme: {$theme_name}",
  ];
  $reasons = $this->moduleRequiredByThemeUninstallValidator
    ->validate($module);
  $this
    ->assertEquals($expected, $reasons);
}