From 7f99b389e280a7be2f0640b92af6fc69e36dcd63 Mon Sep 17 00:00:00 2001
From: Ted Bowman <ted@tedbow.com>
Date: Fri, 22 Oct 2021 16:43:25 -0400
Subject: [PATCH] Revert "use event classes instead of event names"

This reverts commit c8871e5d470b19cb4b5e047f6522371b1d5cf0a7.
---
 src/AutomaticUpdatesEvents.php                | 69 +++++++++++++++++++
 src/Event/ExcludedPathsSubscriber.php         |  5 +-
 src/Event/PostCommitEvent.php                 | 10 ---
 src/Event/PreCommitEvent.php                  |  2 -
 src/Event/PreStartEvent.php                   |  3 -
 src/Event/ReadinessCheckEvent.php             |  9 ---
 src/Event/UpdateEvent.php                     |  9 ++-
 src/Event/UpdateRefreshSubscriber.php         |  3 +-
 src/Updater.php                               | 13 ++--
 src/Validation/ReadinessValidationManager.php |  7 +-
 src/Validator/ComposerExecutableValidator.php |  4 +-
 src/Validator/CoreComposerValidator.php       |  3 +-
 src/Validator/DiskSpaceValidator.php          |  4 +-
 src/Validator/PendingUpdatesValidator.php     |  7 +-
 src/Validator/StagedProjectsValidator.php     |  3 +-
 src/Validator/UpdateVersionValidator.php      |  6 +-
 src/Validator/WritableFileSystemValidator.php |  7 +-
 .../src/ReadinessChecker/TestChecker1.php     | 20 +++---
 .../src/ReadinessChecker/TestChecker2.php     |  7 +-
 tests/src/Functional/UpdaterFormTest.php      |  8 +--
 20 files changed, 122 insertions(+), 77 deletions(-)
 create mode 100644 src/AutomaticUpdatesEvents.php
 delete mode 100644 src/Event/PostCommitEvent.php

diff --git a/src/AutomaticUpdatesEvents.php b/src/AutomaticUpdatesEvents.php
new file mode 100644
index 0000000000..dedef4e0cd
--- /dev/null
+++ b/src/AutomaticUpdatesEvents.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace Drupal\automatic_updates;
+
+/**
+ * Defines events for the automatic_updates module.
+ *
+ * These events allow listeners to validate updates at various points in the
+ * update process.  Listeners to these events should add validation results via
+ * \Drupal\automatic_updates\Event\UpdateEvent::addValidationResult() if
+ * necessary. Only error level validation results will stop an update from
+ * continuing.
+ *
+ * @see \Drupal\automatic_updates\Event\UpdateEvent
+ * @see \Drupal\automatic_updates\Validation\ValidationResult
+ */
+final class AutomaticUpdatesEvents {
+
+  /**
+   * Name of the event fired when checking if the site could perform an update.
+   *
+   * An update is not actually being started when this event is being fired. It
+   * should be used to notify site admins if the site is in a state which will
+   * not allow automatic updates to succeed.
+   *
+   * This event should only be dispatched from ReadinessValidationManager to
+   * allow caching of the results.
+   *
+   * @Event
+   *
+   * @see \Drupal\automatic_updates\Validation\ReadinessValidationManager
+   *
+   * @var string
+   */
+  const READINESS_CHECK = 'automatic_updates.readiness_check';
+
+  /**
+   * Name of the event fired when an automatic update is starting.
+   *
+   * This event is fired before any files are staged. Validation results added
+   * by subscribers are not cached.
+   *
+   * @Event
+   *
+   * @var string
+   */
+  const PRE_START = 'automatic_updates.pre_start';
+
+  /**
+   * Name of the event fired when an automatic update is about to be committed.
+   *
+   * Validation results added by subscribers are not cached.
+   *
+   * @Event
+   *
+   * @var string
+   */
+  const PRE_COMMIT = 'automatic_updates.pre_commit';
+
+  /**
+   * Name of the event fired when a staged update has been committed.
+   *
+   * @Event
+   *
+   * @var string
+   */
+  const POST_COMMIT = 'automatic_updates.post_commit';
+
+}
diff --git a/src/Event/ExcludedPathsSubscriber.php b/src/Event/ExcludedPathsSubscriber.php
index be81f1ab56..457af907f8 100644
--- a/src/Event/ExcludedPathsSubscriber.php
+++ b/src/Event/ExcludedPathsSubscriber.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\automatic_updates\Event;
 
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\Core\File\FileSystemInterface;
 use Drupal\Core\StreamWrapper\LocalStream;
 use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
@@ -157,8 +158,8 @@ class ExcludedPathsSubscriber implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      PreStartEvent::class => 'preStart',
-      PreCommitEvent::class => 'preCommit',
+      AutomaticUpdatesEvents::PRE_START => 'preStart',
+      AutomaticUpdatesEvents::PRE_COMMIT => 'preCommit',
     ];
   }
 
diff --git a/src/Event/PostCommitEvent.php b/src/Event/PostCommitEvent.php
deleted file mode 100644
index e4e166dff8..0000000000
--- a/src/Event/PostCommitEvent.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace Drupal\automatic_updates\Event;
-
-/**
- * Event fired when a staged update has been committed.
- */
-class PostCommitEvent extends UpdateEvent {
-
-}
diff --git a/src/Event/PreCommitEvent.php b/src/Event/PreCommitEvent.php
index f568d9cdd9..1bffb85f5b 100644
--- a/src/Event/PreCommitEvent.php
+++ b/src/Event/PreCommitEvent.php
@@ -6,8 +6,6 @@ use Drupal\package_manager\ComposerUtility;
 
 /**
  * Event fired before staged changes are copied into the active site.
- *
- * Validation results added by subscribers are not cached.
  */
 class PreCommitEvent extends UpdateEvent {
 
diff --git a/src/Event/PreStartEvent.php b/src/Event/PreStartEvent.php
index 3fd40f35b3..d8ce9ec7be 100644
--- a/src/Event/PreStartEvent.php
+++ b/src/Event/PreStartEvent.php
@@ -6,9 +6,6 @@ use Drupal\package_manager\ComposerUtility;
 
 /**
  * Event fired before an update begins.
- *
- * This event is fired before any files are staged. Validation results added
- * by subscribers are not cached.
  */
 class PreStartEvent extends UpdateEvent {
 
diff --git a/src/Event/ReadinessCheckEvent.php b/src/Event/ReadinessCheckEvent.php
index 74a9190c6f..4c165cd972 100644
--- a/src/Event/ReadinessCheckEvent.php
+++ b/src/Event/ReadinessCheckEvent.php
@@ -6,15 +6,6 @@ use Drupal\package_manager\ComposerUtility;
 
 /**
  * Event fired when checking if the site could perform an update.
- *
- * An update is not actually being started when this event is being fired. It
- * should be used to notify site admins if the site is in a state which will
- * not allow automatic updates to succeed.
- *
- * This event should only be dispatched from ReadinessValidationManager to
- * allow caching of the results.
- *
- * @see \Drupal\automatic_updates\Validation\ReadinessValidationManager
  */
 class ReadinessCheckEvent extends UpdateEvent {
 
diff --git a/src/Event/UpdateEvent.php b/src/Event/UpdateEvent.php
index cb4acd816c..0fb3f30fbd 100644
--- a/src/Event/UpdateEvent.php
+++ b/src/Event/UpdateEvent.php
@@ -9,12 +9,11 @@ use Drupal\package_manager\ComposerUtility;
 /**
  * Event fired when a site is updating.
  *
- * These events allow listeners to validate updates at various points in the
- * update process.  Listeners to these events should add validation results via
- * ::addValidationResult() if necessary. Only error level validation results
- * will stop an update from continuing.
+ * Subscribers to this event should call ::addValidationResult().
+ *
+ * @see \Drupal\automatic_updates\AutomaticUpdatesEvents
  */
-abstract class UpdateEvent extends Event {
+class UpdateEvent extends Event {
 
   /**
    * The validation results.
diff --git a/src/Event/UpdateRefreshSubscriber.php b/src/Event/UpdateRefreshSubscriber.php
index fd68151a59..1a3378fbae 100644
--- a/src/Event/UpdateRefreshSubscriber.php
+++ b/src/Event/UpdateRefreshSubscriber.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\automatic_updates\Event;
 
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\update\UpdateManagerInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 
@@ -40,7 +41,7 @@ class UpdateRefreshSubscriber implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      PostCommitEvent::class => ['clearData', 1000],
+      AutomaticUpdatesEvents::POST_COMMIT => ['clearData', 1000],
     ];
   }
 
diff --git a/src/Updater.php b/src/Updater.php
index d3d6e4df11..66158618d1 100644
--- a/src/Updater.php
+++ b/src/Updater.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\automatic_updates;
 
-use Drupal\automatic_updates\Event\PostCommitEvent;
 use Drupal\automatic_updates\Event\PreCommitEvent;
 use Drupal\automatic_updates\Event\PreStartEvent;
 use Drupal\automatic_updates\Event\UpdateEvent;
@@ -118,7 +117,7 @@ class Updater {
     }
     $stage_key = $this->createActiveStage($packages);
     /** @var \Drupal\automatic_updates\Event\PreStartEvent $event */
-    $event = $this->dispatchUpdateEvent(new PreStartEvent($composer, $packages));
+    $event = $this->dispatchUpdateEvent(new PreStartEvent($composer, $packages), AutomaticUpdatesEvents::PRE_START);
     $this->stage->create($this->getExclusions($event));
     return $stage_key;
   }
@@ -158,9 +157,9 @@ class Updater {
     $stage_composer = ComposerUtility::createForDirectory($stage_dir);
 
     /** @var \Drupal\automatic_updates\Event\PreCommitEvent $event */
-    $event = $this->dispatchUpdateEvent(new PreCommitEvent($active_composer, $stage_composer));
+    $event = $this->dispatchUpdateEvent(new PreCommitEvent($active_composer, $stage_composer), AutomaticUpdatesEvents::PRE_COMMIT);
     $this->stage->apply($this->getExclusions($event));
-    $this->dispatchUpdateEvent(new PostCommitEvent($active_composer));
+    $this->dispatchUpdateEvent(new UpdateEvent($active_composer), AutomaticUpdatesEvents::POST_COMMIT);
   }
 
   /**
@@ -202,6 +201,8 @@ class Updater {
    *
    * @param \Drupal\automatic_updates\Event\UpdateEvent $event
    *   The update event.
+   * @param string $event_name
+   *   The name of the event to dispatch.
    *
    * @return \Drupal\automatic_updates\Event\UpdateEvent
    *   The event object.
@@ -209,8 +210,8 @@ class Updater {
    * @throws \Drupal\automatic_updates\Exception\UpdateException
    *   If any of the event subscribers adds a validation error.
    */
-  public function dispatchUpdateEvent(UpdateEvent $event): UpdateEvent {
-    $this->eventDispatcher->dispatch($event);
+  public function dispatchUpdateEvent(UpdateEvent $event, string $event_name): UpdateEvent {
+    $this->eventDispatcher->dispatch($event, $event_name);
     if ($checker_results = $event->getResults(SystemManager::REQUIREMENT_ERROR)) {
       throw new UpdateException($checker_results,
         "Unable to complete the update because of errors.");
diff --git a/src/Validation/ReadinessValidationManager.php b/src/Validation/ReadinessValidationManager.php
index fb73fd5a84..6f2a9bfd22 100644
--- a/src/Validation/ReadinessValidationManager.php
+++ b/src/Validation/ReadinessValidationManager.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\automatic_updates\Validation;
 
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates\UpdateRecommender;
 use Drupal\Component\Datetime\TimeInterface;
@@ -92,13 +93,13 @@ class ReadinessValidationManager {
       $package_versions = [];
     }
     $event = new ReadinessCheckEvent($composer, $package_versions);
-    $this->eventDispatcher->dispatch($event);
+    $this->eventDispatcher->dispatch($event, AutomaticUpdatesEvents::READINESS_CHECK);
     $results = $event->getResults();
     $this->keyValueExpirable->setWithExpire(
       'readiness_validation_last_run',
       [
         'results' => $results,
-        'listeners' => $this->getListenersAsString(ReadinessCheckEvent::class),
+        'listeners' => $this->getListenersAsString(AutomaticUpdatesEvents::READINESS_CHECK),
       ],
       $this->resultsTimeToLive * 60 * 60
     );
@@ -179,7 +180,7 @@ class ReadinessValidationManager {
     $last_run = $this->keyValueExpirable->get('readiness_validation_last_run');
 
     // If the listeners have not changed return the results.
-    if ($last_run && $last_run['listeners'] === $this->getListenersAsString(ReadinessCheckEvent::class)) {
+    if ($last_run && $last_run['listeners'] === $this->getListenersAsString(AutomaticUpdatesEvents::READINESS_CHECK)) {
       return $last_run['results'];
     }
     return NULL;
diff --git a/src/Validator/ComposerExecutableValidator.php b/src/Validator/ComposerExecutableValidator.php
index 2a5dd90423..90a507cb1b 100644
--- a/src/Validator/ComposerExecutableValidator.php
+++ b/src/Validator/ComposerExecutableValidator.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\Event\ReadinessCheckEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\Extension\ExtensionVersion;
@@ -91,7 +91,7 @@ class ComposerExecutableValidator implements EventSubscriberInterface, ProcessOu
    */
   public static function getSubscribedEvents() {
     return [
-      ReadinessCheckEvent::class => 'checkForComposerExecutable',
+      AutomaticUpdatesEvents::READINESS_CHECK => 'checkForComposerExecutable',
     ];
   }
 
diff --git a/src/Validator/CoreComposerValidator.php b/src/Validator/CoreComposerValidator.php
index 700d0210a8..928da62046 100644
--- a/src/Validator/CoreComposerValidator.php
+++ b/src/Validator/CoreComposerValidator.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -41,7 +42,7 @@ class CoreComposerValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      ReadinessCheckEvent::class => ['checkCoreRequirements', 1000],
+      AutomaticUpdatesEvents::READINESS_CHECK => ['checkCoreRequirements', 1000],
     ];
   }
 
diff --git a/src/Validator/DiskSpaceValidator.php b/src/Validator/DiskSpaceValidator.php
index 3b1858d582..9b53192ce0 100644
--- a/src/Validator/DiskSpaceValidator.php
+++ b/src/Validator/DiskSpaceValidator.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\Event\ReadinessCheckEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Component\FileSystem\FileSystem;
@@ -165,7 +165,7 @@ class DiskSpaceValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      ReadinessCheckEvent::class => 'checkDiskSpace',
+      AutomaticUpdatesEvents::READINESS_CHECK => 'checkDiskSpace',
     ];
   }
 
diff --git a/src/Validator/PendingUpdatesValidator.php b/src/Validator/PendingUpdatesValidator.php
index de6d63e3bd..02c3d686a0 100644
--- a/src/Validator/PendingUpdatesValidator.php
+++ b/src/Validator/PendingUpdatesValidator.php
@@ -2,8 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\Event\PreStartEvent;
-use Drupal\automatic_updates\Event\ReadinessCheckEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -77,8 +76,8 @@ class PendingUpdatesValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      PreStartEvent::class => 'checkPendingUpdates',
-      ReadinessCheckEvent::class => 'checkPendingUpdates',
+      AutomaticUpdatesEvents::PRE_START => 'checkPendingUpdates',
+      AutomaticUpdatesEvents::READINESS_CHECK => 'checkPendingUpdates',
     ];
   }
 
diff --git a/src/Validator/StagedProjectsValidator.php b/src/Validator/StagedProjectsValidator.php
index 769203a422..455c965764 100644
--- a/src/Validator/StagedProjectsValidator.php
+++ b/src/Validator/StagedProjectsValidator.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\PreCommitEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -123,7 +124,7 @@ final class StagedProjectsValidator implements EventSubscriberInterface {
    * {@inheritdoc}
    */
   public static function getSubscribedEvents() {
-    $events[PreCommitEvent::class][] = ['validateStagedProjects'];
+    $events[AutomaticUpdatesEvents::PRE_COMMIT][] = ['validateStagedProjects'];
     return $events;
   }
 
diff --git a/src/Validator/UpdateVersionValidator.php b/src/Validator/UpdateVersionValidator.php
index b46d34a0dc..56c5fe1915 100644
--- a/src/Validator/UpdateVersionValidator.php
+++ b/src/Validator/UpdateVersionValidator.php
@@ -3,7 +3,7 @@
 namespace Drupal\automatic_updates\Validator;
 
 use Composer\Semver\Semver;
-use Drupal\automatic_updates\Event\PreStartEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
@@ -101,8 +101,8 @@ class UpdateVersionValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      PreStartEvent::class => 'checkUpdateVersion',
-      ReadinessCheckEvent::class => 'checkReadinessUpdateVersion',
+      AutomaticUpdatesEvents::PRE_START => 'checkUpdateVersion',
+      AutomaticUpdatesEvents::READINESS_CHECK => 'checkReadinessUpdateVersion',
     ];
   }
 
diff --git a/src/Validator/WritableFileSystemValidator.php b/src/Validator/WritableFileSystemValidator.php
index 0417d7b539..792a78da7b 100644
--- a/src/Validator/WritableFileSystemValidator.php
+++ b/src/Validator/WritableFileSystemValidator.php
@@ -2,8 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\Event\PreStartEvent;
-use Drupal\automatic_updates\Event\ReadinessCheckEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -84,8 +83,8 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      ReadinessCheckEvent::class => 'checkPermissions',
-      PreStartEvent::class => 'checkPermissions',
+      AutomaticUpdatesEvents::READINESS_CHECK => 'checkPermissions',
+      AutomaticUpdatesEvents::PRE_START => 'checkPermissions',
     ];
   }
 
diff --git a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
index 916b6f4be2..89f2bb964f 100644
--- a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
+++ b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
@@ -2,9 +2,7 @@
 
 namespace Drupal\automatic_updates_test\ReadinessChecker;
 
-use Drupal\automatic_updates\Event\PreCommitEvent;
-use Drupal\automatic_updates\Event\PreStartEvent;
-use Drupal\automatic_updates\Event\ReadinessCheckEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\Core\State\StateInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -47,9 +45,9 @@ class TestChecker1 implements EventSubscriberInterface {
    *   stored results.
    * @param string $event_name
    *   (optional )The event name. Defaults to
-   *   ReadinessCheckEvent::class.
+   *   AutomaticUpdatesEvents::READINESS_CHECK.
    */
-  public static function setTestResult($checker_results, string $event_name = ReadinessCheckEvent::class): void {
+  public static function setTestResult($checker_results, string $event_name = AutomaticUpdatesEvents::READINESS_CHECK): void {
     $key = static::STATE_KEY . ".$event_name";
 
     if (isset($checker_results)) {
@@ -85,7 +83,7 @@ class TestChecker1 implements EventSubscriberInterface {
    *   The update event.
    */
   public function runPreChecks(UpdateEvent $event): void {
-    $this->addResults($event, static::STATE_KEY . "." . ReadinessCheckEvent::class);
+    $this->addResults($event, static::STATE_KEY . "." . AutomaticUpdatesEvents::READINESS_CHECK);
   }
 
   /**
@@ -95,7 +93,7 @@ class TestChecker1 implements EventSubscriberInterface {
    *   The update event.
    */
   public function runPreCommitChecks(UpdateEvent $event): void {
-    $this->addResults($event, static::STATE_KEY . "." . PreCommitEvent::class);
+    $this->addResults($event, static::STATE_KEY . "." . AutomaticUpdatesEvents::PRE_COMMIT);
   }
 
   /**
@@ -105,7 +103,7 @@ class TestChecker1 implements EventSubscriberInterface {
    *   The update event.
    */
   public function runStartChecks(UpdateEvent $event): void {
-    $this->addResults($event, static::STATE_KEY . "." . PreStartEvent::class);
+    $this->addResults($event, static::STATE_KEY . "." . AutomaticUpdatesEvents::PRE_START);
   }
 
   /**
@@ -113,9 +111,9 @@ class TestChecker1 implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     $priority = defined('AUTOMATIC_UPDATES_TEST_SET_PRIORITY') ? AUTOMATIC_UPDATES_TEST_SET_PRIORITY : 5;
-    $events[ReadinessCheckEvent::class][] = ['runPreChecks', $priority];
-    $events[PreStartEvent::class][] = ['runStartChecks', $priority];
-    $events[PreCommitEvent::class][] = ['runPreCommitChecks', $priority];
+    $events[AutomaticUpdatesEvents::READINESS_CHECK][] = ['runPreChecks', $priority];
+    $events[AutomaticUpdatesEvents::PRE_START][] = ['runStartChecks', $priority];
+    $events[AutomaticUpdatesEvents::PRE_COMMIT][] = ['runPreCommitChecks', $priority];
     return $events;
   }
 
diff --git a/tests/modules/automatic_updates_test2/src/ReadinessChecker/TestChecker2.php b/tests/modules/automatic_updates_test2/src/ReadinessChecker/TestChecker2.php
index dfad950052..da0b88c736 100644
--- a/tests/modules/automatic_updates_test2/src/ReadinessChecker/TestChecker2.php
+++ b/tests/modules/automatic_updates_test2/src/ReadinessChecker/TestChecker2.php
@@ -2,8 +2,7 @@
 
 namespace Drupal\automatic_updates_test2\ReadinessChecker;
 
-use Drupal\automatic_updates\Event\PreStartEvent;
-use Drupal\automatic_updates\Event\ReadinessCheckEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
 
 /**
@@ -14,8 +13,8 @@ class TestChecker2 extends TestChecker1 {
   protected const STATE_KEY = 'automatic_updates_test2.checker_results';
 
   public static function getSubscribedEvents() {
-    $events[ReadinessCheckEvent::class][] = ['runPreChecks', 4];
-    $events[PreStartEvent::class][] = ['runStartChecks', 4];
+    $events[AutomaticUpdatesEvents::READINESS_CHECK][] = ['runPreChecks', 4];
+    $events[AutomaticUpdatesEvents::PRE_START][] = ['runStartChecks', 4];
 
     return $events;
   }
diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php
index 193bc951ba..dc4fc895e8 100644
--- a/tests/src/Functional/UpdaterFormTest.php
+++ b/tests/src/Functional/UpdaterFormTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\automatic_updates\Functional;
 
-use Drupal\automatic_updates\Event\PreStartEvent;
+use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\automatic_updates\Exception\UpdateException;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
@@ -177,7 +177,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
     // Repackage the validation error as an exception, so we can test what
     // happens if a validator throws once the update has started.
     $error = new UpdateException($expected_results, 'The update exploded.');
-    TestChecker1::setTestResult($error, PreStartEvent::class);
+    TestChecker1::setTestResult($error, AutomaticUpdatesEvents::PRE_START);
     $session->reload();
     $assert_session->pageTextNotContains(static::$errorsExplanation);
     $assert_session->pageTextNotContains(static::$warningsExplanation);
@@ -193,7 +193,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
 
     // If a validator flags an error, but doesn't throw, the update should still
     // be halted.
-    TestChecker1::setTestResult($expected_results, PreStartEvent::class);
+    TestChecker1::setTestResult($expected_results, AutomaticUpdatesEvents::PRE_START);
     $this->deleteStagedUpdate();
     $page->pressButton('Update');
     $this->checkForMetaRefresh();
@@ -206,7 +206,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
     // If a validator flags a warning, but doesn't throw, the update should
     // continue.
     $expected_results = $this->testResults['checker_1']['1 warning'];
-    TestChecker1::setTestResult($expected_results, PreStartEvent::class);
+    TestChecker1::setTestResult($expected_results, AutomaticUpdatesEvents::PRE_START);
     $session->reload();
     $this->deleteStagedUpdate();
     $page->pressButton('Update');
-- 
GitLab