From 9fe72b11b22005c4b20d373ed9d44054baafcdbf Mon Sep 17 00:00:00 2001 From: Yash Rode <57207-yash.rode@users.noreply.drupalcode.org> Date: Tue, 21 Feb 2023 20:35:20 +0000 Subject: [PATCH] Issue #3342137 by yash.rode, phenaproxima, Wim Leers: Rename validator methods to `validate` unless there different methods for different events --- .../src/Validator/ComposerExecutableValidator.php | 10 +++++----- .../src/Validator/ComposerJsonExistsValidator.php | 8 ++++---- .../Validator/ComposerMinimumStabilityValidator.php | 4 ++-- .../src/Validator/ComposerPatchesValidator.php | 8 ++++---- .../src/Validator/ComposerPluginsValidator.php | 10 +++++----- .../src/Validator/ComposerSettingsValidator.php | 10 +++++----- package_manager/src/Validator/DiskSpaceValidator.php | 10 +++++----- .../src/Validator/DuplicateInfoFileValidator.php | 4 ++-- .../src/Validator/EnvironmentSupportValidator.php | 10 +++++----- package_manager/src/Validator/LockFileValidator.php | 10 +++++----- package_manager/src/Validator/MultisiteValidator.php | 10 +++++----- .../Validator/OverwriteExistingPackagesValidator.php | 4 ++-- .../src/Validator/PendingUpdatesValidator.php | 10 +++++----- package_manager/src/Validator/SettingsValidator.php | 10 +++++----- .../src/Validator/StageNotInActiveValidator.php | 6 +++--- .../src/Validator/SupportedReleaseValidator.php | 4 ++-- package_manager/src/Validator/SymlinkValidator.php | 10 +++++----- .../src/Validator/WritableFileSystemValidator.php | 10 +++++----- .../src/Kernel/ComposerJsonExistsValidatorTest.php | 4 ++-- .../src/Kernel/EnvironmentSupportValidatorTest.php | 4 ++-- .../tests/src/Unit/StageNotInActiveValidatorTest.php | 2 +- src/Validator/ScaffoldFilePermissionsValidator.php | 10 +++++----- 22 files changed, 84 insertions(+), 84 deletions(-) diff --git a/package_manager/src/Validator/ComposerExecutableValidator.php b/package_manager/src/Validator/ComposerExecutableValidator.php index 9156c2d414..3d4aeb6a1d 100644 --- a/package_manager/src/Validator/ComposerExecutableValidator.php +++ b/package_manager/src/Validator/ComposerExecutableValidator.php @@ -59,9 +59,9 @@ class ComposerExecutableValidator implements EventSubscriberInterface { ) {} /** - * {@inheritdoc} + * Validates that the Composer executable is the correct version. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { // Return early if Composer is not available. try { // The "Composer is available" precondition requires active and stage @@ -143,9 +143,9 @@ class ComposerExecutableValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/ComposerJsonExistsValidator.php b/package_manager/src/Validator/ComposerJsonExistsValidator.php index d5fdf9a89f..9eb1231436 100644 --- a/package_manager/src/Validator/ComposerJsonExistsValidator.php +++ b/package_manager/src/Validator/ComposerJsonExistsValidator.php @@ -40,9 +40,9 @@ final class ComposerJsonExistsValidator implements EventSubscriberInterface { // Set priority to 190 which puts it just after EnvironmentSupportValidator. // @see \Drupal\package_manager\Validator\EnvironmentSupportValidator return [ - PreCreateEvent::class => ['validateComposerJson', 190], - PreApplyEvent::class => ['validateComposerJson', 190], - StatusCheckEvent::class => ['validateComposerJson', 190], + PreCreateEvent::class => ['validate', 190], + PreApplyEvent::class => ['validate', 190], + StatusCheckEvent::class => ['validate', 190], ]; } @@ -52,7 +52,7 @@ final class ComposerJsonExistsValidator implements EventSubscriberInterface { * @param \Drupal\package_manager\Event\PreOperationStageEvent $event * The event. */ - public function validateComposerJson(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $project_root = $this->pathLocator->getProjectRoot(); if (!file_exists($project_root . '/composer.json')) { $event->addError([$this->t('No composer.json file can be found at @project_root', ['@project_root' => $project_root])]); diff --git a/package_manager/src/Validator/ComposerMinimumStabilityValidator.php b/package_manager/src/Validator/ComposerMinimumStabilityValidator.php index b5ab5d3da7..28efe36294 100644 --- a/package_manager/src/Validator/ComposerMinimumStabilityValidator.php +++ b/package_manager/src/Validator/ComposerMinimumStabilityValidator.php @@ -41,7 +41,7 @@ final class ComposerMinimumStabilityValidator implements EventSubscriberInterfac * @param \Drupal\package_manager\Event\PreRequireEvent $event * The stage event. */ - public function validateMinimumStability(PreRequireEvent $event): void { + public function validate(PreRequireEvent $event): void { $dir = $this->pathLocator->getProjectRoot(); $minimum_stability = $this->inspector->getConfig('minimum-stability', $dir); $requested_packages = $event->getRuntimePackages(); @@ -81,7 +81,7 @@ final class ComposerMinimumStabilityValidator implements EventSubscriberInterfac */ public static function getSubscribedEvents(): array { return [ - PreRequireEvent::class => 'validateMinimumStability', + PreRequireEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/ComposerPatchesValidator.php b/package_manager/src/Validator/ComposerPatchesValidator.php index 4ef054b2d0..17332e32b8 100644 --- a/package_manager/src/Validator/ComposerPatchesValidator.php +++ b/package_manager/src/Validator/ComposerPatchesValidator.php @@ -60,7 +60,7 @@ final class ComposerPatchesValidator implements EventSubscriberInterface { * @param \Drupal\package_manager\Event\PreOperationStageEvent $event * The event object. */ - public function validatePatcher(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $messages = []; $stage = $event->stage; @@ -162,9 +162,9 @@ final class ComposerPatchesValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validatePatcher', - PreApplyEvent::class => 'validatePatcher', - StatusCheckEvent::class => 'validatePatcher', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/ComposerPluginsValidator.php b/package_manager/src/Validator/ComposerPluginsValidator.php index a2dc256d31..32abde46da 100644 --- a/package_manager/src/Validator/ComposerPluginsValidator.php +++ b/package_manager/src/Validator/ComposerPluginsValidator.php @@ -147,9 +147,9 @@ final class ComposerPluginsValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Validates the allowed Composer plugins, both in active and stage. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $stage = $event->stage; // When about to copy the changes from the stage directory to the active @@ -208,9 +208,9 @@ final class ComposerPluginsValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/ComposerSettingsValidator.php b/package_manager/src/Validator/ComposerSettingsValidator.php index 6c934f5244..eefa93945c 100644 --- a/package_manager/src/Validator/ComposerSettingsValidator.php +++ b/package_manager/src/Validator/ComposerSettingsValidator.php @@ -37,9 +37,9 @@ final class ComposerSettingsValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Validates Composer settings. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $dir = $this->pathLocator->getProjectRoot(); try { @@ -63,9 +63,9 @@ final class ComposerSettingsValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/DiskSpaceValidator.php b/package_manager/src/Validator/DiskSpaceValidator.php index a2f36e2a63..b2b3014312 100644 --- a/package_manager/src/Validator/DiskSpaceValidator.php +++ b/package_manager/src/Validator/DiskSpaceValidator.php @@ -94,9 +94,9 @@ class DiskSpaceValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Validates that there is enough free disk space to do stage operations. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $root_path = $this->pathLocator->getProjectRoot(); $vendor_path = $this->pathLocator->getVendorDirectory(); $messages = []; @@ -157,9 +157,9 @@ class DiskSpaceValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/DuplicateInfoFileValidator.php b/package_manager/src/Validator/DuplicateInfoFileValidator.php index c328aa7e9e..fe6fe42c17 100644 --- a/package_manager/src/Validator/DuplicateInfoFileValidator.php +++ b/package_manager/src/Validator/DuplicateInfoFileValidator.php @@ -34,7 +34,7 @@ class DuplicateInfoFileValidator implements EventSubscriberInterface { /** * Validates the stage does not have duplicate info.yml not present in active. */ - public function validateDuplicateInfoFileInStage(PreApplyEvent $event): void { + public function validate(PreApplyEvent $event): void { $active_dir = $this->pathLocator->getProjectRoot(); $stage_dir = $event->stage->getStageDirectory(); $active_info_files = $this->findInfoFiles($active_dir); @@ -72,7 +72,7 @@ class DuplicateInfoFileValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreApplyEvent::class => 'validateDuplicateInfoFileInStage', + PreApplyEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/EnvironmentSupportValidator.php b/package_manager/src/Validator/EnvironmentSupportValidator.php index 206403a68a..36928d5ace 100644 --- a/package_manager/src/Validator/EnvironmentSupportValidator.php +++ b/package_manager/src/Validator/EnvironmentSupportValidator.php @@ -37,9 +37,9 @@ final class EnvironmentSupportValidator implements EventSubscriberInterface { public const VARIABLE_NAME = 'DRUPAL_PACKAGE_MANAGER_NOT_SUPPORTED_HELP_URL'; /** - * {@inheritdoc} + * Checks that this environment supports Package Manager. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $message = $this->t('Package Manager is not supported by your environment.'); $help_url = getenv(static::VARIABLE_NAME); @@ -66,9 +66,9 @@ final class EnvironmentSupportValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => ['validateStagePreOperation', 200], - PreApplyEvent::class => ['validateStagePreOperation', 200], - StatusCheckEvent::class => ['validateStagePreOperation', 200], + PreCreateEvent::class => ['validate', 200], + PreApplyEvent::class => ['validate', 200], + StatusCheckEvent::class => ['validate', 200], ]; } diff --git a/package_manager/src/Validator/LockFileValidator.php b/package_manager/src/Validator/LockFileValidator.php index 4dcbd6dc6d..d54c37cbf9 100644 --- a/package_manager/src/Validator/LockFileValidator.php +++ b/package_manager/src/Validator/LockFileValidator.php @@ -85,9 +85,9 @@ final class LockFileValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Checks that the active lock file is unchanged during stage operations. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { // Early return if the stage is not already created. if ($event instanceof StatusCheckEvent && $event->stage->isAvailable()) { return; @@ -139,9 +139,9 @@ final class LockFileValidator implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [ PreCreateEvent::class => 'storeHash', - PreRequireEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreRequireEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', PostDestroyEvent::class => 'deleteHash', ]; } diff --git a/package_manager/src/Validator/MultisiteValidator.php b/package_manager/src/Validator/MultisiteValidator.php index 614a701b25..6b3b95e5fc 100644 --- a/package_manager/src/Validator/MultisiteValidator.php +++ b/package_manager/src/Validator/MultisiteValidator.php @@ -34,9 +34,9 @@ final class MultisiteValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Validates that the current site is not part of a multisite. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { if ($this->isMultisite()) { $event->addError([ $this->t('Drupal multisite is not supported by Package Manager.'), @@ -65,9 +65,9 @@ final class MultisiteValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/OverwriteExistingPackagesValidator.php b/package_manager/src/Validator/OverwriteExistingPackagesValidator.php index 6ff40f32d7..a401553fca 100644 --- a/package_manager/src/Validator/OverwriteExistingPackagesValidator.php +++ b/package_manager/src/Validator/OverwriteExistingPackagesValidator.php @@ -51,7 +51,7 @@ final class OverwriteExistingPackagesValidator implements EventSubscriberInterfa /** * Validates that new installed packages don't overwrite existing directories. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $stage = $event->stage; $active_composer = $stage->getActiveComposer(); $stage_composer = $stage->getStageComposer(); @@ -96,7 +96,7 @@ final class OverwriteExistingPackagesValidator implements EventSubscriberInterfa */ public static function getSubscribedEvents(): array { return [ - PreApplyEvent::class => 'validateStagePreOperation', + PreApplyEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/PendingUpdatesValidator.php b/package_manager/src/Validator/PendingUpdatesValidator.php index 86dc2dd6bc..335427dd3e 100644 --- a/package_manager/src/Validator/PendingUpdatesValidator.php +++ b/package_manager/src/Validator/PendingUpdatesValidator.php @@ -37,9 +37,9 @@ final class PendingUpdatesValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Validates that there are no pending database updates. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { if ($this->updatesExist()) { $message = $this->t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [ ':update' => Url::fromRoute('system.db_update')->toString(), @@ -71,9 +71,9 @@ final class PendingUpdatesValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + StatusCheckEvent::class => 'validate', + PreApplyEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/SettingsValidator.php b/package_manager/src/Validator/SettingsValidator.php index e0608f5629..9733d5f788 100644 --- a/package_manager/src/Validator/SettingsValidator.php +++ b/package_manager/src/Validator/SettingsValidator.php @@ -25,9 +25,9 @@ final class SettingsValidator implements EventSubscriberInterface { use StringTranslationTrait; /** - * {@inheritdoc} + * Checks that Drupal's settings are valid for Package Manager. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { if (Settings::get('update_fetch_with_http_fallback')) { $event->addError([ $this->t('The <code>update_fetch_with_http_fallback</code> setting must be disabled.'), @@ -40,9 +40,9 @@ final class SettingsValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/StageNotInActiveValidator.php b/package_manager/src/Validator/StageNotInActiveValidator.php index abc602e8fc..5c2f7c2134 100644 --- a/package_manager/src/Validator/StageNotInActiveValidator.php +++ b/package_manager/src/Validator/StageNotInActiveValidator.php @@ -35,7 +35,7 @@ class StageNotInActiveValidator implements EventSubscriberInterface { /** * Check if staging root is a subdirectory of active. */ - public function checkNotInActive(PreOperationStageEvent $event) { + public function validate(PreOperationStageEvent $event) { $project_root = $this->pathLocator->getProjectRoot(); $staging_root = $this->pathLocator->getStagingRoot(); if (str_starts_with($staging_root, $project_root)) { @@ -51,8 +51,8 @@ class StageNotInActiveValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'checkNotInActive', - StatusCheckEvent::class => 'checkNotInActive', + PreCreateEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/SupportedReleaseValidator.php b/package_manager/src/Validator/SupportedReleaseValidator.php index d16336fd42..5fc2e7deed 100644 --- a/package_manager/src/Validator/SupportedReleaseValidator.php +++ b/package_manager/src/Validator/SupportedReleaseValidator.php @@ -68,7 +68,7 @@ final class SupportedReleaseValidator implements EventSubscriberInterface { * @param \Drupal\package_manager\Event\PreApplyEvent $event * The event object. */ - public function checkStagedReleases(PreApplyEvent $event): void { + public function validate(PreApplyEvent $event): void { $active = $event->stage->getActiveComposer(); $staged = $event->stage->getStageComposer(); $updated_packages = array_merge( @@ -121,7 +121,7 @@ final class SupportedReleaseValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreApplyEvent::class => 'checkStagedReleases', + PreApplyEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/SymlinkValidator.php b/package_manager/src/Validator/SymlinkValidator.php index 3fd2888126..efc928bf95 100644 --- a/package_manager/src/Validator/SymlinkValidator.php +++ b/package_manager/src/Validator/SymlinkValidator.php @@ -53,9 +53,9 @@ class SymlinkValidator implements EventSubscriberInterface { ) {} /** - * {@inheritdoc} + * Flags errors if the project root or stage directory contain symbolic links. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $active_dir = $this->pathFactory->create($this->pathLocator->getProjectRoot()); // The precondition requires us to pass both an active and stage directory, @@ -100,9 +100,9 @@ class SymlinkValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/src/Validator/WritableFileSystemValidator.php b/package_manager/src/Validator/WritableFileSystemValidator.php index 3b14ccad7b..96d90f682a 100644 --- a/package_manager/src/Validator/WritableFileSystemValidator.php +++ b/package_manager/src/Validator/WritableFileSystemValidator.php @@ -34,14 +34,14 @@ class WritableFileSystemValidator implements EventSubscriberInterface { } /** - * {@inheritdoc} + * Checks that the file system is writable. * * @todo It might make sense to use a more sophisticated method of testing * writability than is_writable(), since it's not clear if that can return * false negatives/positives due to things like SELinux, exotic file * systems, and so forth. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { $messages = []; $drupal_root = $this->pathLocator->getProjectRoot(); @@ -94,9 +94,9 @@ class WritableFileSystemValidator implements EventSubscriberInterface { */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } diff --git a/package_manager/tests/src/Kernel/ComposerJsonExistsValidatorTest.php b/package_manager/tests/src/Kernel/ComposerJsonExistsValidatorTest.php index 4a3434f13e..6cfeae3f59 100644 --- a/package_manager/tests/src/Kernel/ComposerJsonExistsValidatorTest.php +++ b/package_manager/tests/src/Kernel/ComposerJsonExistsValidatorTest.php @@ -34,7 +34,7 @@ class ComposerJsonExistsValidatorTest extends PackageManagerKernelTestBase { 'No composer.json file can be found at <PROJECT_ROOT>'), ]); foreach ([PreCreateEvent::class, StatusCheckEvent::class] as $event_class) { - $this->assertEventPropagationStopped($event_class, [$this->container->get('package_manager.validator.composer_json_exists'), 'validateComposerJson']); + $this->assertEventPropagationStopped($event_class, [$this->container->get('package_manager.validator.composer_json_exists'), 'validate']); } $this->assertResults([$result], PreCreateEvent::class); $result = ValidationResult::createError( @@ -58,7 +58,7 @@ class ComposerJsonExistsValidatorTest extends PackageManagerKernelTestBase { unlink($this->container->get('package_manager.path_locator') ->getProjectRoot() . '/composer.json'); }); - $this->assertEventPropagationStopped(PreApplyEvent::class, [$this->container->get('package_manager.validator.composer_json_exists'), 'validateComposerJson']); + $this->assertEventPropagationStopped(PreApplyEvent::class, [$this->container->get('package_manager.validator.composer_json_exists'), 'validate']); $this->assertResults([$result], PreApplyEvent::class); } diff --git a/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php b/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php index 6d7c2546f7..8707540cc2 100644 --- a/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php +++ b/package_manager/tests/src/Kernel/EnvironmentSupportValidatorTest.php @@ -27,7 +27,7 @@ class EnvironmentSupportValidatorTest extends PackageManagerKernelTestBase { t('Package Manager is not supported by your environment.'), ]); foreach ([PreCreateEvent::class, StatusCheckEvent::class] as $event_class) { - $this->assertEventPropagationStopped($event_class, [$this->container->get('package_manager.validator.environment_support'), 'validateStagePreOperation']); + $this->assertEventPropagationStopped($event_class, [$this->container->get('package_manager.validator.environment_support'), 'validate']); } $this->assertStatusCheckResults([$result]); $this->assertResults([$result], PreCreateEvent::class); @@ -45,7 +45,7 @@ class EnvironmentSupportValidatorTest extends PackageManagerKernelTestBase { 'Package Manager is not supported by your environment.', ]); - $this->assertEventPropagationStopped(PreApplyEvent::class, [$this->container->get('package_manager.validator.environment_support'), 'validateStagePreOperation']); + $this->assertEventPropagationStopped(PreApplyEvent::class, [$this->container->get('package_manager.validator.environment_support'), 'validate']); $this->assertResults([$result], PreApplyEvent::class); } diff --git a/package_manager/tests/src/Unit/StageNotInActiveValidatorTest.php b/package_manager/tests/src/Unit/StageNotInActiveValidatorTest.php index 219d3f5907..9bcffde9fd 100644 --- a/package_manager/tests/src/Unit/StageNotInActiveValidatorTest.php +++ b/package_manager/tests/src/Unit/StageNotInActiveValidatorTest.php @@ -44,7 +44,7 @@ class StageNotInActiveValidatorTest extends UnitTestCase { $stage_not_in_active_validator = new StageNotInActiveValidator($path_locator); $stage_not_in_active_validator->setStringTranslation($this->getStringTranslationStub()); $event = new PreCreateEvent($stage, ['some/path']); - $stage_not_in_active_validator->checkNotInActive($event); + $stage_not_in_active_validator->validate($event); $this->assertValidationResultsEqual($expected, $event->getResults(), $path_locator); } diff --git a/src/Validator/ScaffoldFilePermissionsValidator.php b/src/Validator/ScaffoldFilePermissionsValidator.php index 6829f36545..ab7b68d2d6 100644 --- a/src/Validator/ScaffoldFilePermissionsValidator.php +++ b/src/Validator/ScaffoldFilePermissionsValidator.php @@ -36,9 +36,9 @@ final class ScaffoldFilePermissionsValidator implements EventSubscriberInterface } /** - * {@inheritdoc} + * Validates that scaffold files have the appropriate permissions. */ - public function validateStagePreOperation(PreOperationStageEvent $event): void { + public function validate(PreOperationStageEvent $event): void { // We only want to do this check if the stage belongs to Automatic Updates. if (!$event->stage instanceof Updater) { return; @@ -123,9 +123,9 @@ final class ScaffoldFilePermissionsValidator implements EventSubscriberInterface */ public static function getSubscribedEvents(): array { return [ - PreCreateEvent::class => 'validateStagePreOperation', - PreApplyEvent::class => 'validateStagePreOperation', - StatusCheckEvent::class => 'validateStagePreOperation', + PreCreateEvent::class => 'validate', + PreApplyEvent::class => 'validate', + StatusCheckEvent::class => 'validate', ]; } -- GitLab