You are here

public function ReadinessValidationTest::testReadinessCheckerUninstall in Automatic Updates 8.2

Tests that checker message for an uninstalled module is not displayed.

File

tests/src/Functional/ReadinessValidationTest.php, line 336

Class

ReadinessValidationTest
Tests readiness validation.

Namespace

Drupal\Tests\automatic_updates\Functional

Code

public function testReadinessCheckerUninstall() : void {
  $assert = $this
    ->assertSession();
  $this
    ->drupalLogin($this->checkerRunnerUser);
  $expected_results_1 = $this->testResults['checker_1']['1 error'];
  TestChecker1::setTestResult($expected_results_1);
  $expected_results_2 = $this->testResults['checker_2']['1 error'];
  TestChecker2::setTestResult($expected_results_2);
  $this->container
    ->get('module_installer')
    ->install([
    'automatic_updates',
    'automatic_updates_test',
    'automatic_updates_test2',
  ]);

  // Check for message on 'admin/structure' instead of the status report
  // because checkers will be run if needed on the status report.
  $this
    ->drupalGet('admin/structure');
  $assert
    ->pageTextContainsOnce($expected_results_1[0]
    ->getMessages()[0]);
  $assert
    ->pageTextContainsOnce($expected_results_2[0]
    ->getMessages()[0]);

  // Confirm that when on of the module is uninstalled the other module's
  // checker result is still displayed.
  $this->container
    ->get('module_installer')
    ->uninstall([
    'automatic_updates_test2',
  ]);
  $this
    ->drupalGet('admin/structure');
  $assert
    ->pageTextNotContains($expected_results_2[0]
    ->getMessages()[0]);
  $assert
    ->pageTextContainsOnce($expected_results_1[0]
    ->getMessages()[0]);

  // Confirm that when on of the module is uninstalled the other module's
  // checker result is still displayed.
  $this->container
    ->get('module_installer')
    ->uninstall([
    'automatic_updates_test',
  ]);
  $this
    ->drupalGet('admin/structure');
  $assert
    ->pageTextNotContains($expected_results_2[0]
    ->getMessages()[0]);
  $assert
    ->pageTextNotContains($expected_results_1[0]
    ->getMessages()[0]);
}