You are here

public function ReadinessValidationManagerTest::testRunOnUninstall in Automatic Updates 8.2

Tests that the manager is run after modules are uninstalled.

File

tests/src/Kernel/ReadinessValidation/ReadinessValidationManagerTest.php, line 127

Class

ReadinessValidationManagerTest
@coversDefaultClass \Drupal\automatic_updates\Validation\ReadinessValidationManager

Namespace

Drupal\Tests\automatic_updates\Kernel\ReadinessValidation

Code

public function testRunOnUninstall() : void {
  $expected_results = [
    array_pop($this->testResults['checker_1']),
    array_pop($this->testResults['checker_2']),
  ];
  TestChecker1::setTestResult($expected_results[0]);
  TestChecker2::setTestResult($expected_results[1]);

  // Confirm that messages from existing modules are displayed when
  // 'automatic_updates' is installed.
  $this->container
    ->get('module_installer')
    ->install([
    'automatic_updates',
    'automatic_updates_test2',
    'help',
  ]);
  $expected_results_all = array_merge($expected_results[0], $expected_results[1]);
  $this
    ->assertCheckerResultsFromManager($expected_results_all);

  // Confirm that the checkers are run when a module that provides a readiness
  // checker is uninstalled.
  $expected_results = [
    array_pop($this->testResults['checker_1']),
  ];
  TestChecker1::setTestResult($expected_results[0]);
  TestChecker2::setTestResult(array_pop($this->testResults['checker_2']));
  $this->container
    ->get('module_installer')
    ->uninstall([
    'automatic_updates_test2',
  ]);
  $this
    ->assertCheckerResultsFromManager($expected_results[0]);

  // Confirm that the checkers are not run when a module that does provide a
  // readiness checker is uninstalled.
  $unexpected_results = [
    array_pop($this->testResults['checker_1']),
  ];
  TestChecker1::setTestResult($unexpected_results[0]);
  $this->container
    ->get('module_installer')
    ->uninstall([
    'help',
  ]);
  $this
    ->assertCheckerResultsFromManager($expected_results[0]);
}