function ModuleRequiredByThemesUninstallValidatorTest::testValidateTwoThemeDependencies

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php \Drupal\Tests\Core\Extension\ModuleRequiredByThemesUninstallValidatorTest::testValidateTwoThemeDependencies()
  2. 10 core/tests/Drupal/Tests/Core/Extension/ModuleRequiredByThemesUninstallValidatorTest.php \Drupal\Tests\Core\Extension\ModuleRequiredByThemesUninstallValidatorTest::testValidateTwoThemeDependencies()
  3. 11.x 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([
        'stable9' => [
            'name' => 'Stable 9',
            '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);
}

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