You are here

public function ReadinessValidationManagerTest::testRunOnInstall in Automatic Updates 8.2

Tests that the manager is run after modules are installed.

File

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

Class

ReadinessValidationManagerTest
@coversDefaultClass \Drupal\automatic_updates\Validation\ReadinessValidationManager

Namespace

Drupal\Tests\automatic_updates\Kernel\ReadinessValidation

Code

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

  // Confirm that messages from an existing module are displayed when
  // 'automatic_updates' is installed.
  $this->container
    ->get('module_installer')
    ->install([
    'automatic_updates',
  ]);
  $this
    ->assertCheckerResultsFromManager($expected_results[0]);

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

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