From 9c6042f762be8982493bfb8c0e79fb5b07e7fa2f Mon Sep 17 00:00:00 2001 From: "Theresa.Grannum" <theresa.grannum@3688861.no-reply.drupal.org> Date: Fri, 15 Jul 2022 16:21:49 +0000 Subject: [PATCH] Issue #3277230 by kunal.sachdev, Theresa.Grannum, tedbow, capysara: Always run readiness checks on status report? --- src/Validation/ReadinessRequirements.php | 2 +- .../Functional/ReadinessValidationTest.php | 22 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Validation/ReadinessRequirements.php b/src/Validation/ReadinessRequirements.php index 9265232c0f..1396ceeece 100644 --- a/src/Validation/ReadinessRequirements.php +++ b/src/Validation/ReadinessRequirements.php @@ -73,7 +73,7 @@ final class ReadinessRequirements implements ContainerInjectionInterface { * Requirements arrays as specified by hook_requirements(). */ public function getRequirements(): array { - $results = $this->readinessCheckerManager->runIfNoStoredResults()->getResults(); + $results = $this->readinessCheckerManager->run()->getResults(); $requirements = []; if (empty($results)) { $requirements['automatic_updates_readiness'] = [ diff --git a/tests/src/Functional/ReadinessValidationTest.php b/tests/src/Functional/ReadinessValidationTest.php index 6be987720e..463a72cee6 100644 --- a/tests/src/Functional/ReadinessValidationTest.php +++ b/tests/src/Functional/ReadinessValidationTest.php @@ -76,9 +76,9 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { public function testReadinessChecksStatusReport(): void { $assert = $this->assertSession(); - // Ensure automated_cron is disabled before installing automatic_updates. This - // ensures we are testing that automatic_updates runs the checkers when the - // module itself is installed and they weren't run on cron. + // Ensure automated_cron is disabled before installing automatic_updates. + // This ensures we are testing that automatic_updates runs the checkers when + // the module itself is installed and they weren't run on cron. $this->assertFalse($this->container->get('module_handler')->moduleExists('automated_cron')); $this->container->get('module_installer')->install(['automatic_updates', 'automatic_updates_test']); @@ -141,41 +141,37 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { 'warning' => $this->createValidationResult(SystemManager::REQUIREMENT_WARNING), ]; TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class); - $key_value->delete('readiness_validation_last_run'); - // Confirm a new message is displayed if the stored messages are deleted. - $this->drupalGet('admin/reports/status'); + // Confirm a new message is displayed if the page is reloaded. + $this->getSession()->reload(); // Confirm that on the status page if there is only 1 warning or error the - // the summaries will not be displayed. + // summaries will not be displayed. $this->assertErrors([$expected_results['error']]); $this->assertWarnings([$expected_results['warning']]); $assert->pageTextNotContains($expected_results['error']->getSummary()); $assert->pageTextNotContains($expected_results['warning']->getSummary()); - $key_value->delete('readiness_validation_last_run'); $expected_results = [ 'error' => $this->createValidationResult(SystemManager::REQUIREMENT_ERROR, 2), 'warning' => $this->createValidationResult(SystemManager::REQUIREMENT_WARNING, 2), ]; TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class); - $this->drupalGet('admin/reports/status'); + $this->getSession()->reload(); // Confirm that both messages and summaries will be displayed on status // report when there multiple messages. $this->assertErrors([$expected_results['error']]); $this->assertWarnings([$expected_results['warning']]); - $key_value->delete('readiness_validation_last_run'); $expected_results = [$this->createValidationResult(SystemManager::REQUIREMENT_WARNING, 2)]; TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class); - $this->drupalGet('admin/reports/status'); + $this->getSession()->reload(); $assert->pageTextContainsOnce('Update readiness checks'); // Confirm that warnings will display on the status report if there are no // errors. $this->assertWarnings($expected_results); - $key_value->delete('readiness_validation_last_run'); $expected_results = [$this->createValidationResult(SystemManager::REQUIREMENT_WARNING)]; TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class); - $this->drupalGet('admin/reports/status'); + $this->getSession()->reload(); $assert->pageTextContainsOnce('Update readiness checks'); $this->assertWarnings($expected_results); } -- GitLab