Skip to content
Snippets Groups Projects
Commit f5e04ca3 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3262303 by phenaproxima: Always run readiness checks when modules are...

Issue #3262303 by phenaproxima: Always run readiness checks when modules are installed or uninstalled
parent 4646e6fc
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ function automatic_updates_modules_installed() { ...@@ -95,7 +95,7 @@ function automatic_updates_modules_installed() {
// case they provide readiness checker services. // case they provide readiness checker services.
/** @var \Drupal\automatic_updates\Validation\ReadinessValidationManager $checker_manager */ /** @var \Drupal\automatic_updates\Validation\ReadinessValidationManager $checker_manager */
$checker_manager = \Drupal::service('automatic_updates.readiness_validation_manager'); $checker_manager = \Drupal::service('automatic_updates.readiness_validation_manager');
$checker_manager->runIfNoStoredResults(); $checker_manager->run();
} }
/** /**
...@@ -106,7 +106,7 @@ function automatic_updates_modules_uninstalled() { ...@@ -106,7 +106,7 @@ function automatic_updates_modules_uninstalled() {
// case they provided readiness checker services. // case they provided readiness checker services.
/** @var \Drupal\automatic_updates\Validation\ReadinessValidationManager $checker_manager */ /** @var \Drupal\automatic_updates\Validation\ReadinessValidationManager $checker_manager */
$checker_manager = \Drupal::service('automatic_updates.readiness_validation_manager'); $checker_manager = \Drupal::service('automatic_updates.readiness_validation_manager');
$checker_manager->runIfNoStoredResults(); $checker_manager->run();
} }
/** /**
......
...@@ -317,19 +317,19 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -317,19 +317,19 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$this->drupalGet('admin/structure'); $this->drupalGet('admin/structure');
$assert->pageTextContainsOnce($expected_results[0]->getMessages()[0]); $assert->pageTextContainsOnce($expected_results[0]->getMessages()[0]);
// Confirm that installing a module that does not provide a new checker does // Confirm that installing a module runs the checkers, even if the new
// not run the checkers on install. // module does not provide any validators.
$unexpected_results = $this->testResults['checker_1']['2 errors 2 warnings']; $previous_results = $expected_results;
TestChecker2::setTestResult($unexpected_results, ReadinessCheckEvent::class); $expected_results = $this->testResults['checker_1']['2 errors 2 warnings'];
TestChecker2::setTestResult($expected_results, ReadinessCheckEvent::class);
$this->container->get('module_installer')->install(['help']); $this->container->get('module_installer')->install(['help']);
// Check for message on 'admin/structure' instead of the status report // Check for messages on 'admin/structure' instead of the status report,
// because checkers will be run if needed on the status report. // because validators will be run if needed on the status report.
$this->drupalGet('admin/structure'); $this->drupalGet('admin/structure');
// Confirm that new checker message is not displayed because the checker was // Confirm that new checker messages are displayed.
// not run again. $assert->pageTextNotContains($previous_results[0]->getMessages()[0]);
$assert->pageTextContainsOnce($expected_results[0]->getMessages()[0]); $assert->pageTextNotContains($expected_results['1:errors']->getMessages()[0]);
$assert->pageTextNotContains($unexpected_results['1:errors']->getMessages()[0]); $assert->pageTextContainsOnce($expected_results['1:errors']->getSummary());
$assert->pageTextNotContains($unexpected_results['1:errors']->getSummary());
} }
/** /**
......
...@@ -112,14 +112,15 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { ...@@ -112,14 +112,15 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
$expected_results_all = array_merge($expected_results[0], $expected_results[1]); $expected_results_all = array_merge($expected_results[0], $expected_results[1]);
$this->assertCheckerResultsFromManager($expected_results_all); $this->assertCheckerResultsFromManager($expected_results_all);
// Confirm that the checkers are not run when a module that does not provide // Confirm that the checkers are run when a module that does not provide a
// a readiness checker is installed. // readiness checker is installed.
$unexpected_results = [ $expected_results = [
array_pop($this->testResults['checker_1']), array_pop($this->testResults['checker_1']),
array_pop($this->testResults['checker_2']), array_pop($this->testResults['checker_2']),
]; ];
TestChecker1::setTestResult($unexpected_results[0], ReadinessCheckEvent::class); TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestChecker2::setTestResult($unexpected_results[1], ReadinessCheckEvent::class); TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
$expected_results_all = array_merge($expected_results[0], $expected_results[1]);
$this->container->get('module_installer')->install(['help']); $this->container->get('module_installer')->install(['help']);
$this->assertCheckerResultsFromManager($expected_results_all); $this->assertCheckerResultsFromManager($expected_results_all);
} }
...@@ -150,12 +151,12 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { ...@@ -150,12 +151,12 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
$this->container->get('module_installer')->uninstall(['automatic_updates_test2']); $this->container->get('module_installer')->uninstall(['automatic_updates_test2']);
$this->assertCheckerResultsFromManager($expected_results[0]); $this->assertCheckerResultsFromManager($expected_results[0]);
// Confirm that the checkers are not run when a module that does provide a // Confirm that the checkers are run when a module that does not provide a
// readiness checker is uninstalled. // readiness checker is uninstalled.
$unexpected_results = [ $expected_results = [
array_pop($this->testResults['checker_1']), array_pop($this->testResults['checker_1']),
]; ];
TestChecker1::setTestResult($unexpected_results[0], ReadinessCheckEvent::class); TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
$this->container->get('module_installer')->uninstall(['help']); $this->container->get('module_installer')->uninstall(['help']);
$this->assertCheckerResultsFromManager($expected_results[0]); $this->assertCheckerResultsFromManager($expected_results[0]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment