diff --git a/src/AutomaticUpdatesEvents.php b/src/AutomaticUpdatesEvents.php deleted file mode 100644 index dedef4e0cd911d9a941b73210d4bf7b53eaee855..0000000000000000000000000000000000000000 --- 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 457af907f8d8c94fe129ee2e02e96dee1ae690c6..be81f1ab567ca19c17e9bcd28a253fe4ced2efdc 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 0000000000000000000000000000000000000000..e4e166dff8819246111a75071ddc243fb1f6eb3e --- /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 1bffb85f5ba047f81da8adb264654ab829dd1a4a..f568d9cdd9442abcf6e3e82cee373aeb8a8fe3eb 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 d8ce9ec7be3dc256e66bfabbd0cbd7bfe41f0233..3fd40f35b323ded5a88bbc9169b4634ac634542d 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 4c165cd97245c1d2af475f07cd363625a75dbe45..74a9190c6fa223469c9953f487ac3c7306e81871 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 0fb3f30fbd12c018841893aa2fd09e2653773a2c..cb4acd816c7d32466bdd4c4c96f9b1bd387e0f6d 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 1a3378fbae66798277a9c3192b74899a2d9d0b30..fd68151a5963cedba1754662843abe5398c44301 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 66158618d1f90aea100134011affea7676661c1b..d3d6e4df1154d1d723277c12cdb3290eeb0f33e9 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 6f2a9bfd22d11d37a8ab008898d823cbc6e96e5e..fb73fd5a84e8ea9a202089f24c0eaf25a6bc63a6 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 90a507cb1b1b50a03f6b39428b6515377b911d3c..2a5dd9042360a03f166ba0a97dd183024fc4808f 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 928da620465665ace25a9bc5f419867ce8f33295..700d0210a86928900d1c1c4ec0cc45294c161c63 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 9b53192ce013ad0f84a5037ce50bb182d57f0016..3b1858d582078e34fadbcbaa948b5aee4dc25184 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 02c3d686a0f7844d6e98a66cdf80937426d5fd54..de6d63e3bde839a9a267c314d72459c2fffef811 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 455c9657642491c37adb275683c1512b31402cd2..769203a42217ea30d55e147ce884618c75643890 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 56c5fe1915604b0acf8df99ca3dce475e03d03ff..b46d34a0dc5dab1af5f4d71f5c874f97fd37cacf 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 792a78da7b6aa70d12dfc27f9e5ca6ca830f8d3b..0417d7b5394546630d72d8607f62e665dd27a59f 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 89f2bb964f791b57993dbb19910ac46890aeb3ab..916b6f4be23bb6b1762544e9351dcafde81cbc3d 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 da0b88c7364d1d147169d7aed194bbdfc97fd3ac..dfad950052b9b62f66a6fcd41c92723ee5899686 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 dc4fc895e8855c2f4cc59ec7b57c73af9755547a..193bc951ba28fe8274e41882decada8f7c83cccb 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');