You are here

public function ModuleRequiredByThemesUninstallValidatorTest::testValidateTwoThemeDependencies in Drupal 10

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

@covers ::validate

File

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

Class

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

Namespace

Drupal\Tests\Core\Extension

Code

public function testValidateTwoThemeDependencies() {
  $module = 'popular_module';
  $module_name = 'Popular Module';
  $theme1 = 'first_theme';
  $theme2 = 'second_theme';
  $theme_name_1 = 'First Theme';
  $theme_name_2 = 'Second Theme';
  $this->themeExtensionList
    ->getAllInstalledInfo()
    ->willReturn([
    'stable' => [
      'name' => 'Stable',
      'dependencies' => [],
    ],
    'claro' => [
      'name' => 'Claro',
      'dependencies' => [],
    ],
    $theme1 => [
      'name' => $theme_name_1,
      'dependencies' => [
        $module,
      ],
    ],
    $theme2 => [
      'name' => $theme_name_2,
      'dependencies' => [
        $module,
      ],
    ],
  ]);
  $this->moduleExtensionList
    ->get($module)
    ->willReturn((object) [
    'info' => [
      'name' => $module_name,
    ],
  ]);
  $expected = [
    "Required by the themes: {$theme_name_1}, {$theme_name_2}",
  ];
  $reasons = $this->moduleRequiredByThemeUninstallValidator
    ->validate($module);
  $this
    ->assertEquals($expected, $reasons);
}