From 0229c2a7c81f4b864849bca5aa2796fa5bc66e0c Mon Sep 17 00:00:00 2001
From: Adam G-H <32250-phenaproxima@users.noreply.drupalcode.org>
Date: Mon, 3 Apr 2023 17:33:18 +0000
Subject: [PATCH] Issue #3351908 by phenaproxima: ValidationResult's messages,
 summary and severity should be public readonly properties

---
 .../src/Event/PreOperationStageEvent.php      |  2 +-
 .../src/Exception/StageEventException.php     |  4 +-
 package_manager/src/ValidationResult.php      | 65 ++++++--------
 .../src/EventSubscriber/TestSubscriber.php    |  6 +-
 .../Kernel/ComposerPatchesValidatorTest.php   |  4 +-
 .../Kernel/ComposerPluginsValidatorTest.php   |  4 +-
 .../Kernel/PackageManagerKernelTestBase.php   |  4 +-
 .../tests/src/Traits/ValidationTestTrait.php  |  8 +-
 .../tests/src/Unit/ValidationResultTest.php   |  8 +-
 src/Form/UpdateFormBase.php                   |  4 +-
 src/StatusCheckMailer.php                     |  2 +-
 src/Validation/AdminStatusCheckMessages.php   |  4 +-
 src/Validation/StatusCheckRequirements.php    |  4 +-
 src/Validation/StatusChecker.php              |  2 +-
 .../Functional/StagedDatabaseUpdateTest.php   |  2 +-
 tests/src/Functional/StatusCheckTest.php      | 84 +++++++++----------
 tests/src/Functional/UpdateErrorTest.php      |  4 +-
 tests/src/Functional/UpdaterFormTestBase.php  |  8 +-
 .../StatusCheck/CronServerValidatorTest.php   |  2 +-
 .../ScaffoldFilePermissionsValidatorTest.php  |  2 +-
 .../StatusCheck/XdebugValidatorTest.php       |  2 +-
 21 files changed, 104 insertions(+), 121 deletions(-)

diff --git a/package_manager/src/Event/PreOperationStageEvent.php b/package_manager/src/Event/PreOperationStageEvent.php
index b5c9a51545..63d6997116 100644
--- a/package_manager/src/Event/PreOperationStageEvent.php
+++ b/package_manager/src/Event/PreOperationStageEvent.php
@@ -33,7 +33,7 @@ abstract class PreOperationStageEvent extends StageEvent {
   public function getResults(?int $severity = NULL): array {
     if ($severity !== NULL) {
       return array_filter($this->results, function ($result) use ($severity) {
-        return $result->getSeverity() === $severity;
+        return $result->severity === $severity;
       });
     }
     return $this->results;
diff --git a/package_manager/src/Exception/StageEventException.php b/package_manager/src/Exception/StageEventException.php
index 971faf1e26..fa665221bc 100644
--- a/package_manager/src/Exception/StageEventException.php
+++ b/package_manager/src/Exception/StageEventException.php
@@ -42,8 +42,8 @@ class StageEventException extends StageException {
     $text = '';
     if ($this->event instanceof PreOperationStageEvent) {
       foreach ($this->event->getResults() as $result) {
-        $messages = $result->getMessages();
-        $summary = $result->getSummary();
+        $messages = $result->messages;
+        $summary = $result->summary;
         if ($summary) {
           array_unshift($messages, $summary);
         }
diff --git a/package_manager/src/ValidationResult.php b/package_manager/src/ValidationResult.php
index aafd42a239..700862231a 100644
--- a/package_manager/src/ValidationResult.php
+++ b/package_manager/src/ValidationResult.php
@@ -10,6 +10,8 @@ use Drupal\system\SystemManager;
 
 /**
  * A value object to contain the results of a validation.
+ *
+ * @property \Drupal\Core\StringTranslation\TranslatableMarkup[] $messages
  */
 final class ValidationResult {
 
@@ -20,9 +22,9 @@ final class ValidationResult {
    *   The severity of the result. Should be one of the
    *   SystemManager::REQUIREMENT_* constants.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup[]|string[] $messages
-   *   The error messages.
+   *   The result messages.
    * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $summary
-   *   A summary of the result messages.
+   *   A succinct summary of the result.
    * @param bool $assert_translatable
    *   Whether to assert the messages are translatable. Internal use only.
    *
@@ -30,7 +32,7 @@ final class ValidationResult {
    *   Thrown if $messages is empty, or if it has 2 or more items but $summary
    *   is NULL.
    */
-  private function __construct(protected int $severity, protected array $messages, protected ?TranslatableMarkup $summary, bool $assert_translatable) {
+  private function __construct(public readonly int $severity, private array $messages, public readonly ?TranslatableMarkup $summary, bool $assert_translatable) {
     if ($assert_translatable) {
       assert(Inspector::assertAll(fn ($message) => $message instanceof TranslatableMarkup, $messages));
     }
@@ -42,6 +44,18 @@ final class ValidationResult {
     }
   }
 
+  /**
+   * Implements magic ::__get() method.
+   */
+  public function __get(string $name): mixed {
+    return match ($name) {
+      // The messages must be private so that they cannot be mutated by external
+      // code, but we want to allow callers to access them in the same way as
+      // $this->summary and $this->severity.
+      'messages' => $this->messages,
+    };
+  }
+
   /**
    * Creates an error ValidationResult object from a throwable.
    *
@@ -52,7 +66,7 @@ final class ValidationResult {
    *
    * @return static
    */
-  public static function createErrorFromThrowable(\Throwable $throwable, ?TranslatableMarkup $summary = NULL): self {
+  public static function createErrorFromThrowable(\Throwable $throwable, ?TranslatableMarkup $summary = NULL): static {
     return new static(SystemManager::REQUIREMENT_ERROR, [$throwable->getMessage()], $summary, FALSE);
   }
 
@@ -66,7 +80,7 @@ final class ValidationResult {
    *
    * @return static
    */
-  public static function createError(array $messages, ?TranslatableMarkup $summary = NULL): self {
+  public static function createError(array $messages, ?TranslatableMarkup $summary = NULL): static {
     return new static(SystemManager::REQUIREMENT_ERROR, $messages, $summary, TRUE);
   }
 
@@ -80,41 +94,10 @@ final class ValidationResult {
    *
    * @return static
    */
-  public static function createWarning(array $messages, ?TranslatableMarkup $summary = NULL): self {
+  public static function createWarning(array $messages, ?TranslatableMarkup $summary = NULL): static {
     return new static(SystemManager::REQUIREMENT_WARNING, $messages, $summary, TRUE);
   }
 
-  /**
-   * Gets the summary.
-   *
-   * @return \Drupal\Core\StringTranslation\TranslatableMarkup|null
-   *   The summary.
-   */
-  public function getSummary(): ?TranslatableMarkup {
-    return $this->summary;
-  }
-
-  /**
-   * Gets the messages.
-   *
-   * @return \Drupal\Core\StringTranslation\TranslatableMarkup[]|string[]
-   *   The error or warning messages.
-   */
-  public function getMessages(): array {
-    return $this->messages;
-  }
-
-  /**
-   * The severity of the result.
-   *
-   * @return int
-   *   Either SystemManager::REQUIREMENT_ERROR or
-   *   SystemManager::REQUIREMENT_WARNING.
-   */
-  public function getSeverity(): int {
-    return $this->severity;
-  }
-
   /**
    * Returns the overall severity for a set of validation results.
    *
@@ -127,7 +110,7 @@ final class ValidationResult {
    */
   public static function getOverallSeverity(array $results): int {
     foreach ($results as $result) {
-      if ($result->getSeverity() === SystemManager::REQUIREMENT_ERROR) {
+      if ($result->severity === SystemManager::REQUIREMENT_ERROR) {
         return SystemManager::REQUIREMENT_ERROR;
       }
     }
@@ -149,9 +132,9 @@ final class ValidationResult {
    */
   public static function isEqual(self $a, self $b): bool {
     return (
-      $a->getSeverity() === $b->getSeverity() &&
-      strval($a->getSummary()) === strval($b->getSummary()) &&
-      array_map('strval', $a->getMessages()) === array_map('strval', $b->getMessages())
+      $a->severity === $b->severity &&
+      strval($a->summary) === strval($b->summary) &&
+      array_map('strval', $a->messages) === array_map('strval', $b->messages)
     );
   }
 
diff --git a/package_manager/tests/modules/package_manager_test_validation/src/EventSubscriber/TestSubscriber.php b/package_manager/tests/modules/package_manager_test_validation/src/EventSubscriber/TestSubscriber.php
index 39102ba4ed..4a74187565 100644
--- a/package_manager/tests/modules/package_manager_test_validation/src/EventSubscriber/TestSubscriber.php
+++ b/package_manager/tests/modules/package_manager_test_validation/src/EventSubscriber/TestSubscriber.php
@@ -144,11 +144,11 @@ class TestSubscriber implements EventSubscriberInterface {
     }
     /** @var \Drupal\package_manager\ValidationResult $result */
     foreach ($results as $result) {
-      if ($result->getSeverity() === SystemManager::REQUIREMENT_ERROR) {
-        $event->addError($result->getMessages(), $result->getSummary());
+      if ($result->severity === SystemManager::REQUIREMENT_ERROR) {
+        $event->addError($result->messages, $result->summary);
       }
       else {
-        $event->addWarning($result->getMessages(), $result->getSummary());
+        $event->addWarning($result->messages, $result->summary);
       }
     }
   }
diff --git a/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php b/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php
index 9a842d67b6..ddd35059cd 100644
--- a/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php
+++ b/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php
@@ -271,7 +271,7 @@ class ComposerPatchesValidatorTest extends PackageManagerKernelTestBase {
     $this->enableModules(['help']);
 
     foreach ($expected_results as $result_index => $result) {
-      $messages = $result->getMessages();
+      $messages = $result->messages;
 
       foreach ($messages as $message_index => $message) {
         if ($help_page_sections[$message_index]) {
@@ -284,7 +284,7 @@ class ComposerPatchesValidatorTest extends PackageManagerKernelTestBase {
           $messages[$message_index] = t('@message See <a href=":url">the help page</a> for information on how to resolve the problem.', ['@message' => $message, ':url' => $url]);
         }
       }
-      $expected_results[$result_index] = ValidationResult::createError($messages, $result->getSummary());
+      $expected_results[$result_index] = ValidationResult::createError($messages, $result->summary);
     }
     $this->testErrorDuringPreApply($in_active, $in_stage, $expected_results);
   }
diff --git a/package_manager/tests/src/Kernel/ComposerPluginsValidatorTest.php b/package_manager/tests/src/Kernel/ComposerPluginsValidatorTest.php
index 0fc04a2859..73b8939c9d 100644
--- a/package_manager/tests/src/Kernel/ComposerPluginsValidatorTest.php
+++ b/package_manager/tests/src/Kernel/ComposerPluginsValidatorTest.php
@@ -110,7 +110,7 @@ class ComposerPluginsValidatorTest extends PackageManagerKernelTestBase {
   public function testValidationAfterTrustingDuringPreCreate(array $composer_config_to_add, array $packages_to_add, array $expected_results): void {
     $expected_results_without_composer_plugin_violations = array_filter(
       $expected_results,
-      fn (ValidationResult $v) => !$v->getSummary() || !str_contains(strtolower($v->getSummary()->getUntranslatedString()), 'unsupported composer plugin'),
+      fn (ValidationResult $v) => !$v->summary || !str_contains(strtolower($v->summary->getUntranslatedString()), 'unsupported composer plugin'),
     );
 
     // Trust all added packages.
@@ -132,7 +132,7 @@ class ComposerPluginsValidatorTest extends PackageManagerKernelTestBase {
   public function testValidationAfterTrustingDuringPreApply(array $composer_config_to_add, array $packages_to_add, array $expected_results): void {
     $expected_results_without_composer_plugin_violations = array_filter(
       $expected_results,
-      fn (ValidationResult $v) => !$v->getSummary() || !str_contains(strtolower($v->getSummary()->getUntranslatedString()), 'unsupported composer plugin'),
+      fn (ValidationResult $v) => !$v->summary || !str_contains(strtolower($v->summary->getUntranslatedString()), 'unsupported composer plugin'),
     );
 
     // Trust all added packages.
diff --git a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
index 19aff68a97..aec20eaa1d 100644
--- a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
+++ b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
@@ -399,8 +399,8 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
     $event = new $event_class($stage ?? $this->createStage(), []);
 
     foreach ($expected_results as $result) {
-      if ($result->getSeverity() === SystemManager::REQUIREMENT_ERROR) {
-        $event->addError($result->getMessages(), $result->getSummary());
+      if ($result->severity === SystemManager::REQUIREMENT_ERROR) {
+        $event->addError($result->messages, $result->summary);
       }
     }
     return new StageEventException($event);
diff --git a/package_manager/tests/src/Traits/ValidationTestTrait.php b/package_manager/tests/src/Traits/ValidationTestTrait.php
index c3f27a1c67..02228d0023 100644
--- a/package_manager/tests/src/Traits/ValidationTestTrait.php
+++ b/package_manager/tests/src/Traits/ValidationTestTrait.php
@@ -111,15 +111,15 @@ trait ValidationTestTrait {
           $message = new TranslatableMarkup($message->getUntranslatedString(), $message->getArguments(), $message->getOptions(), $string_translation_stub);
         }
         return (string) $message;
-      }, $result->getMessages());
+      }, $result->messages);
 
-      $summary = $result->getSummary();
+      $summary = $result->summary;
       if ($summary !== NULL) {
-        $summary = (string) $result->getSummary();
+        $summary = (string) $result->summary;
       }
 
       return [
-        'severity' => $result->getSeverity(),
+        'severity' => $result->severity,
         'messages' => $messages,
         'summary' => $summary,
       ];
diff --git a/package_manager/tests/src/Unit/ValidationResultTest.php b/package_manager/tests/src/Unit/ValidationResultTest.php
index 3651c4d926..f3b0ed4af3 100644
--- a/package_manager/tests/src/Unit/ValidationResultTest.php
+++ b/package_manager/tests/src/Unit/ValidationResultTest.php
@@ -161,15 +161,15 @@ class ValidationResultTest extends UnitTestCase {
    *   The severity.
    */
   protected function assertResultValid(ValidationResult $result, array $expected_messages, ?TranslatableMarkup $summary, int $severity): void {
-    $this->assertSame($expected_messages, $result->getMessages());
+    $this->assertSame($expected_messages, $result->messages);
     if ($summary === NULL) {
-      $this->assertNull($result->getSummary());
+      $this->assertNull($result->summary);
     }
     else {
-      $this->assertSame($summary->getUntranslatedString(), $result->getSummary()
+      $this->assertSame($summary->getUntranslatedString(), $result->summary
         ->getUntranslatedString());
     }
-    $this->assertSame($severity, $result->getSeverity());
+    $this->assertSame($severity, $result->severity);
   }
 
 }
diff --git a/src/Form/UpdateFormBase.php b/src/Form/UpdateFormBase.php
index ea0bb61262..15f39e340e 100644
--- a/src/Form/UpdateFormBase.php
+++ b/src/Form/UpdateFormBase.php
@@ -64,11 +64,11 @@ abstract class UpdateFormBase extends FormBase {
       '#prefix' => $this->getFailureMessageForSeverity($severity),
     ];
     foreach ($results as $result) {
-      $messages = $result->getMessages();
+      $messages = $result->messages;
 
       // If there's a summary, there's guaranteed to be at least one message,
       // so render the result as a nested list.
-      $summary = $result->getSummary();
+      $summary = $result->summary;
       if ($summary) {
         $build['#items'][] = [
           '#theme' => $build['#theme'],
diff --git a/src/StatusCheckMailer.php b/src/StatusCheckMailer.php
index c25adf3679..f23b35df96 100644
--- a/src/StatusCheckMailer.php
+++ b/src/StatusCheckMailer.php
@@ -82,7 +82,7 @@ final class StatusCheckMailer {
     // result sets.
     elseif ($level === static::ERRORS_ONLY) {
       $filter = function (ValidationResult $result): bool {
-        return $result->getSeverity() === SystemManager::REQUIREMENT_ERROR;
+        return $result->severity === SystemManager::REQUIREMENT_ERROR;
       };
       $current_results = array_filter($current_results, $filter);
       // If the current results don't have any errors, there's nothing else
diff --git a/src/Validation/AdminStatusCheckMessages.php b/src/Validation/AdminStatusCheckMessages.php
index 920059c402..a187e31f69 100644
--- a/src/Validation/AdminStatusCheckMessages.php
+++ b/src/Validation/AdminStatusCheckMessages.php
@@ -188,8 +188,8 @@ final class AdminStatusCheckMessages implements ContainerInjectionInterface {
     // want to alert users that problems exist, but not burden them with the
     // details. They can get those on the status report and updater form.
     $format_result = function (ValidationResult $result): TranslatableMarkup {
-      $messages = $result->getMessages();
-      return $result->getSummary() ?: reset($messages);
+      $messages = $result->messages;
+      return $result->summary ?: reset($messages);
     };
     // Format the results as a single item list prefixed by a preamble message.
     $build = [
diff --git a/src/Validation/StatusCheckRequirements.php b/src/Validation/StatusCheckRequirements.php
index e799f27b89..482063aa6b 100644
--- a/src/Validation/StatusCheckRequirements.php
+++ b/src/Validation/StatusCheckRequirements.php
@@ -97,8 +97,8 @@ final class StatusCheckRequirements implements ContainerInjectionInterface {
       return NULL;
     }
     foreach ($results as $result) {
-      $checker_messages = $result->getMessages();
-      $summary = $result->getSummary();
+      $checker_messages = $result->messages;
+      $summary = $result->summary;
       if (empty($summary)) {
         $severity_messages[] = ['#markup' => array_pop($checker_messages)];
       }
diff --git a/src/Validation/StatusChecker.php b/src/Validation/StatusChecker.php
index 444b13ce9e..e7f74502e0 100644
--- a/src/Validation/StatusChecker.php
+++ b/src/Validation/StatusChecker.php
@@ -113,7 +113,7 @@ final class StatusChecker implements EventSubscriberInterface {
     if ($results !== NULL) {
       if ($severity !== NULL) {
         $results = array_filter($results, function ($result) use ($severity) {
-          return $result->getSeverity() === $severity;
+          return $result->severity === $severity;
         });
       }
       return $results;
diff --git a/tests/src/Functional/StagedDatabaseUpdateTest.php b/tests/src/Functional/StagedDatabaseUpdateTest.php
index 96c91c3b7d..4d5fcbc5e0 100644
--- a/tests/src/Functional/StagedDatabaseUpdateTest.php
+++ b/tests/src/Functional/StagedDatabaseUpdateTest.php
@@ -54,7 +54,7 @@ class StagedDatabaseUpdateTest extends UpdaterFormTestBase {
     // on the updater form.
     $expected_results = [$this->createValidationResult(SystemManager::REQUIREMENT_WARNING)];
     TestSubscriber1::setTestResult($expected_results, StatusCheckEvent::class);
-    $messages = reset($expected_results)->getMessages();
+    $messages = reset($expected_results)->messages;
 
     StagedDatabaseUpdateValidator::setExtensionsWithUpdates([
       'system',
diff --git a/tests/src/Functional/StatusCheckTest.php b/tests/src/Functional/StatusCheckTest.php
index f74d7f8f89..51cc7f5040 100644
--- a/tests/src/Functional/StatusCheckTest.php
+++ b/tests/src/Functional/StatusCheckTest.php
@@ -104,7 +104,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // Cron Updates will always be disabled on installation as per
     // automatic_updates.settings.yml .
     $session = $this->assertSession();
-    $session->pageTextNotContains($expected_result->getMessages()[0]);
+    $session->pageTextNotContains($expected_result->messages[0]);
     $session->linkExists('See status report for more details.');
   }
 
@@ -299,7 +299,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     $assert->pageTextContainsOnce('Your site has not recently run an update readiness check. Rerun readiness checks now.');
     $this->clickLink('Rerun readiness checks now.');
     $assert->addressEquals(Url::fromRoute($admin_route));
-    $assert->pageTextContainsOnce($expected_results[0]->getSummary());
+    $assert->pageTextContainsOnce($expected_results[0]->summary);
 
     $expected_results = [
       '1 error' => $this->createValidationResult(SystemManager::REQUIREMENT_ERROR),
@@ -312,13 +312,13 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     $this->drupalGet(Url::fromRoute($admin_route));
     $assert->pageTextContainsOnce(static::$errorsExplanation);
     // Confirm on admin pages that the summary will be displayed.
-    $this->assertSame(SystemManager::REQUIREMENT_ERROR, $expected_results['1 error']->getSeverity());
-    $assert->pageTextContainsOnce((string) $expected_results['1 error']->getSummary());
-    $assert->pageTextNotContains($expected_results['1 error']->getMessages()[0]);
+    $this->assertSame(SystemManager::REQUIREMENT_ERROR, $expected_results['1 error']->severity);
+    $assert->pageTextContainsOnce((string) $expected_results['1 error']->summary);
+    $assert->pageTextNotContains($expected_results['1 error']->messages[0]);
     // Warnings are not displayed on admin pages if there are any errors.
-    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results['1 warning']->getSeverity());
-    $assert->pageTextNotContains($expected_results['1 warning']->getMessages()[0]);
-    $assert->pageTextNotContains($expected_results['1 warning']->getSummary());
+    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results['1 warning']->severity);
+    $assert->pageTextNotContains($expected_results['1 warning']->messages[0]);
+    $assert->pageTextNotContains($expected_results['1 warning']->summary);
 
     // Confirm that if cron runs less than hour after it previously ran it will
     // not run the checkers again.
@@ -330,10 +330,10 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     $this->delayRequestTime(30);
     $this->cronRun();
     $this->drupalGet(Url::fromRoute($admin_route));
-    $assert->pageTextNotContains($unexpected_results['2 errors']->getSummary());
-    $assert->pageTextContainsOnce((string) $expected_results['1 error']->getSummary());
-    $assert->pageTextNotContains($unexpected_results['2 warnings']->getSummary());
-    $assert->pageTextNotContains($expected_results['1 warning']->getMessages()[0]);
+    $assert->pageTextNotContains($unexpected_results['2 errors']->summary);
+    $assert->pageTextContainsOnce((string) $expected_results['1 error']->summary);
+    $assert->pageTextNotContains($unexpected_results['2 warnings']->summary);
+    $assert->pageTextNotContains($expected_results['1 warning']->messages[0]);
 
     // Confirm that is if cron is run over an hour after the checkers were
     // previously run the checkers will be run again.
@@ -343,16 +343,16 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     $this->drupalGet(Url::fromRoute($admin_route));
     // Confirm on admin pages only the error summary will be displayed if there
     // is more than 1 error.
-    $this->assertSame(SystemManager::REQUIREMENT_ERROR, $expected_results['2 errors']->getSeverity());
-    $assert->pageTextNotContains($expected_results['2 errors']->getMessages()[0]);
-    $assert->pageTextNotContains($expected_results['2 errors']->getMessages()[1]);
-    $assert->pageTextContainsOnce($expected_results['2 errors']->getSummary());
+    $this->assertSame(SystemManager::REQUIREMENT_ERROR, $expected_results['2 errors']->severity);
+    $assert->pageTextNotContains($expected_results['2 errors']->messages[0]);
+    $assert->pageTextNotContains($expected_results['2 errors']->messages[1]);
+    $assert->pageTextContainsOnce($expected_results['2 errors']->summary);
     $assert->pageTextContainsOnce(static::$errorsExplanation);
     // Warnings are not displayed on admin pages if there are any errors.
-    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results['2 warnings']->getSeverity());
-    $assert->pageTextNotContains($expected_results['2 warnings']->getMessages()[0]);
-    $assert->pageTextNotContains($expected_results['2 warnings']->getMessages()[1]);
-    $assert->pageTextNotContains($expected_results['2 warnings']->getSummary());
+    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results['2 warnings']->severity);
+    $assert->pageTextNotContains($expected_results['2 warnings']->messages[0]);
+    $assert->pageTextNotContains($expected_results['2 warnings']->messages[1]);
+    $assert->pageTextNotContains($expected_results['2 warnings']->summary);
 
     $expected_results = [$this->createValidationResult(SystemManager::REQUIREMENT_WARNING, 2)];
     TestSubscriber1::setTestResult($expected_results, StatusCheckEvent::class);
@@ -362,11 +362,11 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // Confirm that the warnings summary is displayed on admin pages if there
     // are no errors.
     $assert->pageTextNotContains(static::$errorsExplanation);
-    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results[0]->getSeverity());
-    $assert->pageTextNotContains($expected_results[0]->getMessages()[0]);
-    $assert->pageTextNotContains($expected_results[0]->getMessages()[1]);
+    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results[0]->severity);
+    $assert->pageTextNotContains($expected_results[0]->messages[0]);
+    $assert->pageTextNotContains($expected_results[0]->messages[1]);
     $assert->pageTextContainsOnce(static::$warningsExplanation);
-    $assert->pageTextContainsOnce($expected_results[0]->getSummary());
+    $assert->pageTextContainsOnce($expected_results[0]->summary);
 
     $expected_results = [$this->createValidationResult(SystemManager::REQUIREMENT_WARNING)];
     TestSubscriber1::setTestResult($expected_results, StatusCheckEvent::class);
@@ -376,10 +376,10 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     $assert->pageTextNotContains(static::$errorsExplanation);
     // Confirm that a single warning is displayed and not the summary on admin
     // pages if there is only 1 warning and there are no errors.
-    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results[0]->getSeverity());
+    $this->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results[0]->severity);
     $assert->pageTextContainsOnce(static::$warningsExplanation);
-    $assert->pageTextContainsOnce((string) $expected_results[0]->getSummary());
-    $assert->pageTextNotContains($expected_results[0]->getMessages()[0]);
+    $assert->pageTextContainsOnce((string) $expected_results[0]->summary);
+    $assert->pageTextNotContains($expected_results[0]->messages[0]);
 
     // Confirm status check messages are not displayed when cron updates are
     // disabled.
@@ -387,7 +387,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     $this->drupalGet('admin/structure');
     $this->checkForMetaRefresh();
     $assert->pageTextNotContains(static::$warningsExplanation);
-    $assert->pageTextNotContains($expected_results[0]->getMessages()[0]);
+    $assert->pageTextNotContains($expected_results[0]->messages[0]);
   }
 
   /**
@@ -413,7 +413,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     TestSubscriber2::setTestResult($expected_results, StatusCheckEvent::class);
     $this->container->get('module_installer')->install(['automatic_updates_test2']);
     $this->drupalGet('admin/structure');
-    $assert->pageTextContainsOnce((string) $expected_results[0]->getSummary());
+    $assert->pageTextContainsOnce((string) $expected_results[0]->summary);
 
     // Confirm that installing a module runs the checkers, even if the new
     // module does not provide any validators.
@@ -428,9 +428,9 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // because validators will be run if needed on the status report.
     $this->drupalGet('admin/structure');
     // Confirm that new checker messages are displayed.
-    $assert->pageTextNotContains($previous_results[0]->getMessages()[0]);
-    $assert->pageTextNotContains($expected_results['2 errors']->getMessages()[0]);
-    $assert->pageTextContainsOnce($expected_results['2 errors']->getSummary());
+    $assert->pageTextNotContains($previous_results[0]->messages[0]);
+    $assert->pageTextNotContains($expected_results['2 errors']->messages[0]);
+    $assert->pageTextContainsOnce($expected_results['2 errors']->summary);
   }
 
   /**
@@ -452,22 +452,22 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // 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]->getSummary());
-    $assert->pageTextContainsOnce($expected_results_2[0]->getSummary());
+    $assert->pageTextContainsOnce($expected_results_1[0]->summary);
+    $assert->pageTextContainsOnce($expected_results_2[0]->summary);
 
     // 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]->getSummary());
-    $assert->pageTextContainsOnce($expected_results_1[0]->getSummary());
+    $assert->pageTextNotContains($expected_results_2[0]->summary);
+    $assert->pageTextContainsOnce($expected_results_1[0]->summary);
 
     // 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]);
+    $assert->pageTextNotContains($expected_results_2[0]->messages[0]);
+    $assert->pageTextNotContains($expected_results_1[0]->messages[0]);
   }
 
   /**
@@ -487,7 +487,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // area.
     $results = [$this->createValidationResult(SystemManager::REQUIREMENT_ERROR)];
     TestSubscriber1::setTestResult($results, StatusCheckEvent::class);
-    $message = $results[0]->getSummary();
+    $message = $results[0]->summary;
 
     $this->container->get('module_installer')->install([
       'automatic_updates',
@@ -537,7 +537,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // area.
     $result = $this->createValidationResult(SystemManager::REQUIREMENT_ERROR);
     TestSubscriber1::setTestResult([$result], StatusCheckEvent::class);
-    $message = $result->getSummary();
+    $message = $result->summary;
 
     $this->container->get('module_installer')->install([
       'automatic_updates',
@@ -647,8 +647,8 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase {
     // Convert the expected results into strings.
     $expected_messages = [];
     foreach ($expected_results as $result) {
-      $messages = $result->getMessages();
-      $summary = $result->getSummary();
+      $messages = $result->messages;
+      $summary = $result->summary;
       if ($summary) {
         $expected_messages[] = $summary;
       }
diff --git a/tests/src/Functional/UpdateErrorTest.php b/tests/src/Functional/UpdateErrorTest.php
index f318e8492c..b5666fb012 100644
--- a/tests/src/Functional/UpdateErrorTest.php
+++ b/tests/src/Functional/UpdateErrorTest.php
@@ -145,8 +145,8 @@ class UpdateErrorTest extends UpdaterFormTestBase {
     // messages or summary, because exceptions thrown directly by event
     // subscribers are wrapped in simple exceptions and re-thrown.
     $assert_session->pageTextContainsOnce($error->getMessage());
-    $assert_session->pageTextNotContains((string) $expected_results[0]->getMessages()[0]);
-    $assert_session->pageTextNotContains($expected_results[0]->getSummary());
+    $assert_session->pageTextNotContains((string) $expected_results[0]->messages[0]);
+    $assert_session->pageTextNotContains($expected_results[0]->summary);
     $assert_session->pageTextNotContains($cached_message);
     // Since the error occurred during pre-create, there should be no existing
     // update to delete.
diff --git a/tests/src/Functional/UpdaterFormTestBase.php b/tests/src/Functional/UpdaterFormTestBase.php
index a0851535e7..1a5d6a1a34 100644
--- a/tests/src/Functional/UpdaterFormTestBase.php
+++ b/tests/src/Functional/UpdaterFormTestBase.php
@@ -137,10 +137,10 @@ abstract class UpdaterFormTestBase extends AutomaticUpdatesFunctionalTestBase {
    */
   protected function assertStatusMessageContainsResult(ValidationResult $result): void {
     $assert_session = $this->assertSession();
-    $type = $result->getSeverity() === SystemManager::REQUIREMENT_ERROR ? 'error' : 'warning';
-    $assert_session->statusMessageContains((string) $result->getSummary(), $type);
-    $assert_session->pageTextContainsOnce((string) $result->getSummary());
-    foreach ($result->getMessages() as $message) {
+    $type = $result->severity === SystemManager::REQUIREMENT_ERROR ? 'error' : 'warning';
+    $assert_session->statusMessageContains((string) $result->summary, $type);
+    $assert_session->pageTextContainsOnce((string) $result->summary);
+    foreach ($result->messages as $message) {
       $assert_session->statusMessageContains((string) $message, $type);
       $assert_session->pageTextContainsOnce((string) $message);
     }
diff --git a/tests/src/Kernel/StatusCheck/CronServerValidatorTest.php b/tests/src/Kernel/StatusCheck/CronServerValidatorTest.php
index 3926a38c9d..122c8e08b9 100644
--- a/tests/src/Kernel/StatusCheck/CronServerValidatorTest.php
+++ b/tests/src/Kernel/StatusCheck/CronServerValidatorTest.php
@@ -224,7 +224,7 @@ class CronServerValidatorTest extends AutomaticUpdatesKernelTestBase {
 
     foreach ($expected_results as $i => $result) {
       $messages = [];
-      foreach ($result->getMessages() as $message) {
+      foreach ($result->messages as $message) {
         $messages[] = t('@message See <a href=":url">the Automatic Updates help page</a> for more information on how to resolve this.', ['@message' => $message, ':url' => $url]);
       }
       $expected_results[$i] = ValidationResult::createError($messages);
diff --git a/tests/src/Kernel/StatusCheck/ScaffoldFilePermissionsValidatorTest.php b/tests/src/Kernel/StatusCheck/ScaffoldFilePermissionsValidatorTest.php
index 08148333c2..7e524e077d 100644
--- a/tests/src/Kernel/StatusCheck/ScaffoldFilePermissionsValidatorTest.php
+++ b/tests/src/Kernel/StatusCheck/ScaffoldFilePermissionsValidatorTest.php
@@ -51,7 +51,7 @@ class ScaffoldFilePermissionsValidatorTest extends AutomaticUpdatesKernelTestBas
     foreach ($expected_results as $i => $result) {
       // Prepend the active directory to every path listed in the error result,
       // and add the expected summary.
-      $messages = array_map($map, $result->getMessages());
+      $messages = array_map($map, $result->messages);
       $messages = array_map(t(...), $messages);
       $expected_results[$i] = ValidationResult::createError($messages, t('The following paths must be writable in order to update default site configuration files.'));
     }
diff --git a/tests/src/Kernel/StatusCheck/XdebugValidatorTest.php b/tests/src/Kernel/StatusCheck/XdebugValidatorTest.php
index f7f87dacac..fc522ded21 100644
--- a/tests/src/Kernel/StatusCheck/XdebugValidatorTest.php
+++ b/tests/src/Kernel/StatusCheck/XdebugValidatorTest.php
@@ -51,7 +51,7 @@ class XdebugValidatorTest extends AutomaticUpdatesKernelTestBase {
     $this->assertUpdateStagedTimes(1);
     $event_dispatcher = \Drupal::service('event_dispatcher');
     $result = $this->runStatusCheck($stage, $event_dispatcher);
-    $this->assertSame($message->getUntranslatedString(), $result[0]->getMessages()[0]->getUntranslatedString());
+    $this->assertSame($message->getUntranslatedString(), $result[0]->messages[0]->getUntranslatedString());
     $stage->destroy(TRUE);
 
     $result = ValidationResult::createWarning([$message]);
-- 
GitLab