function RequiredModuleUninstallValidatorTest::testValidateRequired

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php \Drupal\Tests\Core\Extension\RequiredModuleUninstallValidatorTest::testValidateRequired()
  2. 8.9.x core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php \Drupal\Tests\Core\Extension\RequiredModuleUninstallValidatorTest::testValidateRequired()
  3. 11.x core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php \Drupal\Tests\Core\Extension\RequiredModuleUninstallValidatorTest::testValidateRequired()

@covers ::validate

File

core/tests/Drupal/Tests/Core/Extension/RequiredModuleUninstallValidatorTest.php, line 64

Class

RequiredModuleUninstallValidatorTest
@coversDefaultClass \Drupal\Core\Extension\RequiredModuleUninstallValidator @group Extension

Namespace

Drupal\Tests\Core\Extension

Code

public function testValidateRequired() : void {
    $module = $this->randomMachineName();
    $this->uninstallValidator
        ->expects($this->once())
        ->method('getModuleInfoByModule')
        ->willReturn([
        'required' => TRUE,
        'name' => $module,
    ]);
    $expected = [
        "The {$module} module is required",
    ];
    $reasons = $this->uninstallValidator
        ->validate($module);
    $this->assertEquals($expected, $reasons);
}

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