From c3930ce3d51c9697cb9626985d94b0253cfbdbeb Mon Sep 17 00:00:00 2001
From: tedbow <tedbow@240860.no-reply.drupal.org>
Date: Fri, 22 Oct 2021 21:21:04 +0000
Subject: [PATCH] Issue #3245428 by tedbow: Remove event names and use event
 classes instead.

---
 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, 77 insertions(+), 122 deletions(-)
 delete mode 100644 src/AutomaticUpdatesEvents.php
 create mode 100644 src/Event/PostCommitEvent.php

diff --git a/src/AutomaticUpdatesEvents.php b/src/AutomaticUpdatesEvents.php
deleted file mode 100644
index dedef4e0cd..0000000000
--- a/src/AutomaticUpdatesEvents.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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 457af907f8..be81f1ab56 100644
--- a/src/Event/ExcludedPathsSubscriber.php
+++ b/src/Event/ExcludedPathsSubscriber.php
@@ -2,7 +2,6 @@
 
 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;
@@ -158,8 +157,8 @@ class ExcludedPathsSubscriber implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      AutomaticUpdatesEvents::PRE_START => 'preStart',
-      AutomaticUpdatesEvents::PRE_COMMIT => 'preCommit',
+      PreStartEvent::class => 'preStart',
+      PreCommitEvent::class => 'preCommit',
     ];
   }
 
diff --git a/src/Event/PostCommitEvent.php b/src/Event/PostCommitEvent.php
new file mode 100644
index 0000000000..e4e166dff8
--- /dev/null
+++ b/src/Event/PostCommitEvent.php
@@ -0,0 +1,10 @@
+<?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 1bffb85f5b..f568d9cdd9 100644
--- a/src/Event/PreCommitEvent.php
+++ b/src/Event/PreCommitEvent.php
@@ -6,6 +6,8 @@ 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 d8ce9ec7be..3fd40f35b3 100644
--- a/src/Event/PreStartEvent.php
+++ b/src/Event/PreStartEvent.php
@@ -6,6 +6,9 @@ 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 4c165cd972..74a9190c6f 100644
--- a/src/Event/ReadinessCheckEvent.php
+++ b/src/Event/ReadinessCheckEvent.php
@@ -6,6 +6,15 @@ 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 0fb3f30fbd..cb4acd816c 100644
--- a/src/Event/UpdateEvent.php
+++ b/src/Event/UpdateEvent.php
@@ -9,11 +9,12 @@ use Drupal\package_manager\ComposerUtility;
 /**
  * Event fired when a site is updating.
  *
- * Subscribers to this event should call ::addValidationResult().
- *
- * @see \Drupal\automatic_updates\AutomaticUpdatesEvents
+ * 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.
  */
-class UpdateEvent extends Event {
+abstract class UpdateEvent extends Event {
 
   /**
    * The validation results.
diff --git a/src/Event/UpdateRefreshSubscriber.php b/src/Event/UpdateRefreshSubscriber.php
index 1a3378fbae..fd68151a59 100644
--- a/src/Event/UpdateRefreshSubscriber.php
+++ b/src/Event/UpdateRefreshSubscriber.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\automatic_updates\Event;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
 use Drupal\update\UpdateManagerInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 
@@ -41,7 +40,7 @@ class UpdateRefreshSubscriber implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      AutomaticUpdatesEvents::POST_COMMIT => ['clearData', 1000],
+      PostCommitEvent::class => ['clearData', 1000],
     ];
   }
 
diff --git a/src/Updater.php b/src/Updater.php
index 66158618d1..d3d6e4df11 100644
--- a/src/Updater.php
+++ b/src/Updater.php
@@ -2,6 +2,7 @@
 
 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;
@@ -117,7 +118,7 @@ class Updater {
     }
     $stage_key = $this->createActiveStage($packages);
     /** @var \Drupal\automatic_updates\Event\PreStartEvent $event */
-    $event = $this->dispatchUpdateEvent(new PreStartEvent($composer, $packages), AutomaticUpdatesEvents::PRE_START);
+    $event = $this->dispatchUpdateEvent(new PreStartEvent($composer, $packages));
     $this->stage->create($this->getExclusions($event));
     return $stage_key;
   }
@@ -157,9 +158,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), AutomaticUpdatesEvents::PRE_COMMIT);
+    $event = $this->dispatchUpdateEvent(new PreCommitEvent($active_composer, $stage_composer));
     $this->stage->apply($this->getExclusions($event));
-    $this->dispatchUpdateEvent(new UpdateEvent($active_composer), AutomaticUpdatesEvents::POST_COMMIT);
+    $this->dispatchUpdateEvent(new PostCommitEvent($active_composer));
   }
 
   /**
@@ -201,8 +202,6 @@ 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.
@@ -210,8 +209,8 @@ class Updater {
    * @throws \Drupal\automatic_updates\Exception\UpdateException
    *   If any of the event subscribers adds a validation error.
    */
-  public function dispatchUpdateEvent(UpdateEvent $event, string $event_name): UpdateEvent {
-    $this->eventDispatcher->dispatch($event, $event_name);
+  public function dispatchUpdateEvent(UpdateEvent $event): UpdateEvent {
+    $this->eventDispatcher->dispatch($event);
     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 6f2a9bfd22..fb73fd5a84 100644
--- a/src/Validation/ReadinessValidationManager.php
+++ b/src/Validation/ReadinessValidationManager.php
@@ -2,7 +2,6 @@
 
 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;
@@ -93,13 +92,13 @@ class ReadinessValidationManager {
       $package_versions = [];
     }
     $event = new ReadinessCheckEvent($composer, $package_versions);
-    $this->eventDispatcher->dispatch($event, AutomaticUpdatesEvents::READINESS_CHECK);
+    $this->eventDispatcher->dispatch($event);
     $results = $event->getResults();
     $this->keyValueExpirable->setWithExpire(
       'readiness_validation_last_run',
       [
         'results' => $results,
-        'listeners' => $this->getListenersAsString(AutomaticUpdatesEvents::READINESS_CHECK),
+        'listeners' => $this->getListenersAsString(ReadinessCheckEvent::class),
       ],
       $this->resultsTimeToLive * 60 * 60
     );
@@ -180,7 +179,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(AutomaticUpdatesEvents::READINESS_CHECK)) {
+    if ($last_run && $last_run['listeners'] === $this->getListenersAsString(ReadinessCheckEvent::class)) {
       return $last_run['results'];
     }
     return NULL;
diff --git a/src/Validator/ComposerExecutableValidator.php b/src/Validator/ComposerExecutableValidator.php
index 90a507cb1b..2a5dd90423 100644
--- a/src/Validator/ComposerExecutableValidator.php
+++ b/src/Validator/ComposerExecutableValidator.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 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 [
-      AutomaticUpdatesEvents::READINESS_CHECK => 'checkForComposerExecutable',
+      ReadinessCheckEvent::class => 'checkForComposerExecutable',
     ];
   }
 
diff --git a/src/Validator/CoreComposerValidator.php b/src/Validator/CoreComposerValidator.php
index 928da62046..700d0210a8 100644
--- a/src/Validator/CoreComposerValidator.php
+++ b/src/Validator/CoreComposerValidator.php
@@ -2,7 +2,6 @@
 
 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;
@@ -42,7 +41,7 @@ class CoreComposerValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      AutomaticUpdatesEvents::READINESS_CHECK => ['checkCoreRequirements', 1000],
+      ReadinessCheckEvent::class => ['checkCoreRequirements', 1000],
     ];
   }
 
diff --git a/src/Validator/DiskSpaceValidator.php b/src/Validator/DiskSpaceValidator.php
index 9b53192ce0..3b1858d582 100644
--- a/src/Validator/DiskSpaceValidator.php
+++ b/src/Validator/DiskSpaceValidator.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 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 [
-      AutomaticUpdatesEvents::READINESS_CHECK => 'checkDiskSpace',
+      ReadinessCheckEvent::class => 'checkDiskSpace',
     ];
   }
 
diff --git a/src/Validator/PendingUpdatesValidator.php b/src/Validator/PendingUpdatesValidator.php
index 02c3d686a0..de6d63e3bd 100644
--- a/src/Validator/PendingUpdatesValidator.php
+++ b/src/Validator/PendingUpdatesValidator.php
@@ -2,7 +2,8 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\PreStartEvent;
+use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -76,8 +77,8 @@ class PendingUpdatesValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      AutomaticUpdatesEvents::PRE_START => 'checkPendingUpdates',
-      AutomaticUpdatesEvents::READINESS_CHECK => 'checkPendingUpdates',
+      PreStartEvent::class => 'checkPendingUpdates',
+      ReadinessCheckEvent::class => 'checkPendingUpdates',
     ];
   }
 
diff --git a/src/Validator/StagedProjectsValidator.php b/src/Validator/StagedProjectsValidator.php
index 455c965764..769203a422 100644
--- a/src/Validator/StagedProjectsValidator.php
+++ b/src/Validator/StagedProjectsValidator.php
@@ -2,7 +2,6 @@
 
 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;
@@ -124,7 +123,7 @@ final class StagedProjectsValidator implements EventSubscriberInterface {
    * {@inheritdoc}
    */
   public static function getSubscribedEvents() {
-    $events[AutomaticUpdatesEvents::PRE_COMMIT][] = ['validateStagedProjects'];
+    $events[PreCommitEvent::class][] = ['validateStagedProjects'];
     return $events;
   }
 
diff --git a/src/Validator/UpdateVersionValidator.php b/src/Validator/UpdateVersionValidator.php
index 56c5fe1915..b46d34a0dc 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\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\PreStartEvent;
 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 [
-      AutomaticUpdatesEvents::PRE_START => 'checkUpdateVersion',
-      AutomaticUpdatesEvents::READINESS_CHECK => 'checkReadinessUpdateVersion',
+      PreStartEvent::class => 'checkUpdateVersion',
+      ReadinessCheckEvent::class => 'checkReadinessUpdateVersion',
     ];
   }
 
diff --git a/src/Validator/WritableFileSystemValidator.php b/src/Validator/WritableFileSystemValidator.php
index 792a78da7b..0417d7b539 100644
--- a/src/Validator/WritableFileSystemValidator.php
+++ b/src/Validator/WritableFileSystemValidator.php
@@ -2,7 +2,8 @@
 
 namespace Drupal\automatic_updates\Validator;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\PreStartEvent;
+use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\automatic_updates\Validation\ValidationResult;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -83,8 +84,8 @@ class WritableFileSystemValidator implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     return [
-      AutomaticUpdatesEvents::READINESS_CHECK => 'checkPermissions',
-      AutomaticUpdatesEvents::PRE_START => 'checkPermissions',
+      ReadinessCheckEvent::class => 'checkPermissions',
+      PreStartEvent::class => 'checkPermissions',
     ];
   }
 
diff --git a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
index 89f2bb964f..916b6f4be2 100644
--- a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
+++ b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
@@ -2,7 +2,9 @@
 
 namespace Drupal\automatic_updates_test\ReadinessChecker;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\PreCommitEvent;
+use Drupal\automatic_updates\Event\PreStartEvent;
+use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates\Event\UpdateEvent;
 use Drupal\Core\State\StateInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -45,9 +47,9 @@ class TestChecker1 implements EventSubscriberInterface {
    *   stored results.
    * @param string $event_name
    *   (optional )The event name. Defaults to
-   *   AutomaticUpdatesEvents::READINESS_CHECK.
+   *   ReadinessCheckEvent::class.
    */
-  public static function setTestResult($checker_results, string $event_name = AutomaticUpdatesEvents::READINESS_CHECK): void {
+  public static function setTestResult($checker_results, string $event_name = ReadinessCheckEvent::class): void {
     $key = static::STATE_KEY . ".$event_name";
 
     if (isset($checker_results)) {
@@ -83,7 +85,7 @@ class TestChecker1 implements EventSubscriberInterface {
    *   The update event.
    */
   public function runPreChecks(UpdateEvent $event): void {
-    $this->addResults($event, static::STATE_KEY . "." . AutomaticUpdatesEvents::READINESS_CHECK);
+    $this->addResults($event, static::STATE_KEY . "." . ReadinessCheckEvent::class);
   }
 
   /**
@@ -93,7 +95,7 @@ class TestChecker1 implements EventSubscriberInterface {
    *   The update event.
    */
   public function runPreCommitChecks(UpdateEvent $event): void {
-    $this->addResults($event, static::STATE_KEY . "." . AutomaticUpdatesEvents::PRE_COMMIT);
+    $this->addResults($event, static::STATE_KEY . "." . PreCommitEvent::class);
   }
 
   /**
@@ -103,7 +105,7 @@ class TestChecker1 implements EventSubscriberInterface {
    *   The update event.
    */
   public function runStartChecks(UpdateEvent $event): void {
-    $this->addResults($event, static::STATE_KEY . "." . AutomaticUpdatesEvents::PRE_START);
+    $this->addResults($event, static::STATE_KEY . "." . PreStartEvent::class);
   }
 
   /**
@@ -111,9 +113,9 @@ class TestChecker1 implements EventSubscriberInterface {
    */
   public static function getSubscribedEvents() {
     $priority = defined('AUTOMATIC_UPDATES_TEST_SET_PRIORITY') ? AUTOMATIC_UPDATES_TEST_SET_PRIORITY : 5;
-    $events[AutomaticUpdatesEvents::READINESS_CHECK][] = ['runPreChecks', $priority];
-    $events[AutomaticUpdatesEvents::PRE_START][] = ['runStartChecks', $priority];
-    $events[AutomaticUpdatesEvents::PRE_COMMIT][] = ['runPreCommitChecks', $priority];
+    $events[ReadinessCheckEvent::class][] = ['runPreChecks', $priority];
+    $events[PreStartEvent::class][] = ['runStartChecks', $priority];
+    $events[PreCommitEvent::class][] = ['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 da0b88c736..dfad950052 100644
--- a/tests/modules/automatic_updates_test2/src/ReadinessChecker/TestChecker2.php
+++ b/tests/modules/automatic_updates_test2/src/ReadinessChecker/TestChecker2.php
@@ -2,7 +2,8 @@
 
 namespace Drupal\automatic_updates_test2\ReadinessChecker;
 
-use Drupal\automatic_updates\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\PreStartEvent;
+use Drupal\automatic_updates\Event\ReadinessCheckEvent;
 use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
 
 /**
@@ -13,8 +14,8 @@ class TestChecker2 extends TestChecker1 {
   protected const STATE_KEY = 'automatic_updates_test2.checker_results';
 
   public static function getSubscribedEvents() {
-    $events[AutomaticUpdatesEvents::READINESS_CHECK][] = ['runPreChecks', 4];
-    $events[AutomaticUpdatesEvents::PRE_START][] = ['runStartChecks', 4];
+    $events[ReadinessCheckEvent::class][] = ['runPreChecks', 4];
+    $events[PreStartEvent::class][] = ['runStartChecks', 4];
 
     return $events;
   }
diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php
index dc4fc895e8..193bc951ba 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\AutomaticUpdatesEvents;
+use Drupal\automatic_updates\Event\PreStartEvent;
 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, AutomaticUpdatesEvents::PRE_START);
+    TestChecker1::setTestResult($error, PreStartEvent::class);
     $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, AutomaticUpdatesEvents::PRE_START);
+    TestChecker1::setTestResult($expected_results, PreStartEvent::class);
     $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, AutomaticUpdatesEvents::PRE_START);
+    TestChecker1::setTestResult($expected_results, PreStartEvent::class);
     $session->reload();
     $this->deleteStagedUpdate();
     $page->pressButton('Update');
-- 
GitLab