diff --git a/automatic_updates_extensions/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php b/automatic_updates_extensions/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php index 40b18ef02b37543f45e96f14270382a6e07be469..fd1823f684fc920cbcfaffee1ff58395211536dc 100644 --- a/automatic_updates_extensions/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php +++ b/automatic_updates_extensions/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php @@ -93,7 +93,7 @@ class StatusCheckerRunAfterUpdateTest extends UpdaterFormTestBase { $this->drupalGet('/admin'); // Confirm that the status checks were run and the new error is displayed. $assert_session->statusMessageContains('Error before continue.', 'error'); - $assert_session->statusMessageContains(static::$errorsExplanation, 'error'); + $assert_session->statusMessageContains('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.', 'error'); $assert_session->pageTextNotContains('Your site has not recently run an update readiness check. Rerun readiness checks now.'); } } diff --git a/automatic_updates_extensions/tests/src/Functional/UnsuccessfulUpdateTest.php b/automatic_updates_extensions/tests/src/Functional/UnsuccessfulUpdateTest.php index c9cc155eac2e231ff2721ca11d104c4bb6037301..fd7cc715c8f5c022061d792a11bda54278eb6384 100644 --- a/automatic_updates_extensions/tests/src/Functional/UnsuccessfulUpdateTest.php +++ b/automatic_updates_extensions/tests/src/Functional/UnsuccessfulUpdateTest.php @@ -36,7 +36,8 @@ class UnsuccessfulUpdateTest extends UpdaterFormTestBase { $assert->pageTextNotContains(static::$errorsExplanation); $assert->elementExists('css', '#edit-projects-semver-test')->check(); $assert->checkboxChecked('edit-projects-semver-test'); - $assert->pageTextContains(static::$warningsExplanation); + // No explanation is given for warnings. + $assert->pageTextNotContains(static::$warningsExplanation); $assert->buttonExists('Update'); // Add warnings from StatusCheckEvent. diff --git a/automatic_updates_extensions/tests/src/Functional/UpdaterFormTestBase.php b/automatic_updates_extensions/tests/src/Functional/UpdaterFormTestBase.php index c20f1027d604a7ead1064646f1e002aa5e127cc1..56da072daecf8d618da6939f83314452585b2db9 100644 --- a/automatic_updates_extensions/tests/src/Functional/UpdaterFormTestBase.php +++ b/automatic_updates_extensions/tests/src/Functional/UpdaterFormTestBase.php @@ -18,6 +18,11 @@ abstract class UpdaterFormTestBase extends UpdaterFormFunctionalTestBase { use FormTestTrait; + /** + * {@inheritdoc} + */ + protected static $errorsExplanation = 'Your site cannot be automatically updated until further action is performed.'; + /** * The path of the test project's active directory. * diff --git a/src/Form/UpdateFormBase.php b/src/Form/UpdateFormBase.php index 15f39e340e0a49055275ebdf1deb064ce0017b04..35bc2d93400177c8c861e0e64afbd824802c0b91 100644 --- a/src/Form/UpdateFormBase.php +++ b/src/Form/UpdateFormBase.php @@ -6,7 +6,6 @@ namespace Drupal\automatic_updates\Form; use Drupal\Core\Form\FormBase; use Drupal\Core\Render\RendererInterface; -use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\package_manager\StatusCheckTrait; use Drupal\package_manager\ValidationResult; use Drupal\system\SystemManager; @@ -22,27 +21,6 @@ abstract class UpdateFormBase extends FormBase { use StatusCheckTrait; - /** - * Gets a message, based on severity, when status checks fail. - * - * @param int $severity - * The severity. Should be one of the SystemManager::REQUIREMENT_* - * constants. - * - * @return \Drupal\Core\StringTranslation\TranslatableMarkup - * The message. - * - * @see \Drupal\system\SystemManager::REQUIREMENT_ERROR - * @see \Drupal\system\SystemManager::REQUIREMENT_WARNING - */ - protected function getFailureMessageForSeverity(int $severity): TranslatableMarkup { - return $severity === SystemManager::REQUIREMENT_WARNING ? - // @todo Link "automatic updates" to documentation in - // https://www.drupal.org/node/3168405. - $this->t('Your site does not pass some readiness checks for automatic updates. Depending on the nature of the failures, it might affect the eligibility for automatic updates.') : - $this->t('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.'); - } - /** * Adds a set of validation results to the messages. * @@ -58,11 +36,14 @@ abstract class UpdateFormBase extends FormBase { return; } - // Format the results as a single item list prefixed by a preamble message. + // Format the results as a single item list prefixed by a preamble message + // if necessary. $build = [ '#theme' => 'item_list__automatic_updates_validation_results', - '#prefix' => $this->getFailureMessageForSeverity($severity), ]; + if ($severity === SystemManager::REQUIREMENT_ERROR) { + $build['#prefix'] = $this->t('Your site cannot be automatically updated until further action is performed.'); + } foreach ($results as $result) { $messages = $result->messages; diff --git a/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php b/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php index 4e107e65b6ee8c62a1392b608f3a049d23f1a198..bcb60ffaac942fe89b7864e4675d26f0ddcc0986 100644 --- a/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php +++ b/tests/src/Functional/StatusCheckerRunAfterUpdateTest.php @@ -89,7 +89,7 @@ class StatusCheckerRunAfterUpdateTest extends UpdaterFormTestBase { $this->drupalGet('/admin'); // Confirm that the status checks were run and the new error is displayed. $assert_session->statusMessageContains('Error before continue.', 'error'); - $assert_session->statusMessageContains(static::$errorsExplanation, 'error'); + $assert_session->statusMessageContains('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.', 'error'); $assert_session->pageTextNotContains('Your site has not recently run an update readiness check. Rerun readiness checks now.'); } } diff --git a/tests/src/Functional/UpdaterFormTestBase.php b/tests/src/Functional/UpdaterFormTestBase.php index 1a5d6a1a34b88a76692e3adce3d837caf513696e..3f5f2fb75c0934034a5ec916261847183cb09a74 100644 --- a/tests/src/Functional/UpdaterFormTestBase.php +++ b/tests/src/Functional/UpdaterFormTestBase.php @@ -41,6 +41,7 @@ abstract class UpdaterFormTestBase extends AutomaticUpdatesFunctionalTestBase { * {@inheritdoc} */ protected function setUp(): void { + static::$errorsExplanation = 'Your site cannot be automatically updated until further action is performed.'; parent::setUp(); $this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml');