diff --git a/src/Form/UpdateReady.php b/src/Form/UpdateReady.php index fab06f14e1e9c1bdd9a855316422389ce5c0b6ed..2923d72ce18791d016067a63ee5ef0913dbd7a80 100644 --- a/src/Form/UpdateReady.php +++ b/src/Form/UpdateReady.php @@ -5,6 +5,7 @@ namespace Drupal\automatic_updates\Form; use Drupal\automatic_updates\BatchProcessor; use Drupal\automatic_updates\Updater; use Drupal\automatic_updates\Validation\ReadinessTrait; +use Drupal\package_manager\ValidationResult; use Drupal\package_manager\Validator\StagedDBUpdateValidator; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Extension\ModuleExtensionList; @@ -29,7 +30,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; */ final class UpdateReady extends FormBase { - use ReadinessTrait; + use ReadinessTrait { + formatResult as traitFormatResult; + } /** * The updater service. @@ -274,4 +277,22 @@ final class UpdateReady extends FormBase { } } + /** + * {@inheritdoc} + * + * @todo Remove this in https://www.drupal.org/project/automatic_updates/issues/3313414. + */ + protected function formatResult(ValidationResult $result) { + $messages = $result->getMessages(); + + if (count($messages) > 1) { + return [ + '#theme' => 'item_list__automatic_updates_validation_results', + '#prefix' => $result->getSummary(), + '#items' => $messages, + ]; + } + return $this->traitFormatResult($result); + } + } diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index db866a7bf8951892bd20af66a324f098eb572e2a..4548dd4071462fc28edd4bdd1191ad02bd60529a 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -774,9 +774,20 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $page->pressButton('Update to 9.8.1'); $this->checkForMetaRefresh(); $this->assertUpdateStagedTimes(1); - $error = ValidationResult::createError(['Error occured.']); + + $error_messages = [ + "The only thing we're allowed to do is to", + "believe that we won't regret the choice", + "we made.", + ]; + $summary = t('some generic summary'); + $error = ValidationResult::createError($error_messages, $summary); TestSubscriber::setTestResult([$error], StatusCheckEvent::class); $this->getSession()->reload(); + $assert_session->pageTextContains($summary); + foreach ($error_messages as $message) { + $assert_session->pageTextContains($message); + } $assert_session->buttonNotExists('Continue'); $assert_session->buttonExists('Cancel update'); } @@ -794,13 +805,22 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $this->checkForMetaRefresh(); $this->assertUpdateStagedTimes(1); - $warning = ValidationResult::createWarning(['Some warning.']); + $messages = [ + "The only thing we're allowed to do is to", + "believe that we won't regret the choice", + "we made.", + ]; + $summary = t('some generic summary'); + $warning = ValidationResult::createWarning($messages, $summary); TestSubscriber::setTestResult([$warning], StatusCheckEvent::class); $session->reload(); $assert_session = $this->assertSession(); $assert_session->buttonExists('Continue'); - $assert_session->pageTextContains('Some warning.'); + $assert_session->pageTextContains($summary); + foreach ($messages as $message) { + $assert_session->pageTextContains($message); + } } /**