function ExtensionUninstallCommandTest::testValidatorBlocksUninstall

Tests that a module blocked by an uninstall validator is reported.

File

core/tests/Drupal/KernelTests/Core/Extension/Command/ExtensionUninstallCommandTest.php, line 196

Class

ExtensionUninstallCommandTest
Tests the 'ex:uninstall' command.

Namespace

Drupal\KernelTests\Core\Extension\Command

Code

public function testValidatorBlocksUninstall() : void {
  $this->container
    ->get('module_installer')
    ->install([
    'test_module_required_by_theme',
    'test_another_module_required_by_theme',
  ]);
  $this->container
    ->get('theme_installer')
    ->install([
    'test_theme_depending_on_modules',
  ]);
  $tester = $this->commandTester();
  $code = $tester->execute([
    'extensions' => 'test_module_required_by_theme',
    '--dry-run' => TRUE,
  ]);
  $display = $tester->getDisplay();
  $this->assertEquals(Command::FAILURE, $code, $display);
  $this->assertStringContainsString('Required by the theme', $display);
  $this->assertTrue($this->moduleInstalled('test_module_required_by_theme'));
}

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