diff --git a/automatic_updates.services.yml b/automatic_updates.services.yml index 82a0ba6218b4ca8d1d1af415f40841284c9d744b..84f17872759adcc77c520ef195e8cd8ecb4f2541 100644 --- a/automatic_updates.services.yml +++ b/automatic_updates.services.yml @@ -5,11 +5,6 @@ services: automatic_updates.updater: class: Drupal\automatic_updates\Updater arguments: ['@state', '@string_translation','@automatic_updates.beginner', '@automatic_updates.stager', '@automatic_updates.cleaner', '@automatic_updates.committer', '@event_dispatcher', '@config.factory'] - automatic_updates.staged_package_validator: - class: Drupal\automatic_updates\Validation\StagedProjectsValidation - arguments: ['@string_translation', '@automatic_updates.updater' ] - tags: - - { name: event_subscriber } automatic_updates.beginner: class: PhpTuf\ComposerStager\Domain\Beginner arguments: @@ -76,13 +71,18 @@ services: arguments: ['%app.root%', '%site.path%', '@file_system', '@stream_wrapper_manager'] tags: - { name: event_subscriber } - automatic_updates.update_version_subscriber: - class: Drupal\automatic_updates\Event\UpdateVersionSubscriber + automatic_updates.staged_projects_validator: + class: Drupal\automatic_updates\Validator\StagedProjectsValidator + arguments: [ '@string_translation', '@automatic_updates.updater' ] + tags: + - { name: event_subscriber } + automatic_updates.update_version_validator: + class: Drupal\automatic_updates\Validator\UpdateVersionValidator arguments: ['@automatic_updates.updater'] tags: - { name: event_subscriber } automatic_updates.composer_executable_validator: - class: Drupal\automatic_updates\Validation\ComposerExecutableValidator + class: Drupal\automatic_updates\Validator\ComposerExecutableValidator arguments: ['@automatic_updates.exec_finder'] tags: - { name: event_subscriber } diff --git a/src/Validation/ComposerExecutableValidator.php b/src/Validator/ComposerExecutableValidator.php similarity index 93% rename from src/Validation/ComposerExecutableValidator.php rename to src/Validator/ComposerExecutableValidator.php index 6244e78fde7883a91d215500422e87199afb88f1..ce892f3b612c15346aa8c36d32b11928c71dc994 100644 --- a/src/Validation/ComposerExecutableValidator.php +++ b/src/Validator/ComposerExecutableValidator.php @@ -1,9 +1,10 @@ <?php -namespace Drupal\automatic_updates\Validation; +namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\AutomaticUpdatesEvents; use Drupal\automatic_updates\Event\UpdateEvent; +use Drupal\automatic_updates\Validation\ValidationResult; use PhpTuf\ComposerStager\Exception\IOException; use PhpTuf\ComposerStager\Infrastructure\Process\ExecutableFinderInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; diff --git a/src/Validation/StagedProjectsValidation.php b/src/Validator/StagedProjectsValidator.php similarity index 96% rename from src/Validation/StagedProjectsValidation.php rename to src/Validator/StagedProjectsValidator.php index adbdbbbb8d9e033ef7787573f71d0e41f620cc59..faf6f23752633048a2ceebec9d126884d06c5d5e 100644 --- a/src/Validation/StagedProjectsValidation.php +++ b/src/Validator/StagedProjectsValidator.php @@ -1,20 +1,21 @@ <?php -namespace Drupal\automatic_updates\Validation; +namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\AutomaticUpdatesEvents; use Drupal\automatic_updates\Event\UpdateEvent; use Drupal\automatic_updates\Exception\UpdateException; use Drupal\automatic_updates\Updater; +use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\Component\Serialization\Json; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * An event subscriber that validates staged Drupal projects. + * Validates the staged Drupal projects. */ -final class StagedProjectsValidation implements EventSubscriberInterface { +final class StagedProjectsValidator implements EventSubscriberInterface { use StringTranslationTrait; diff --git a/src/Event/UpdateVersionSubscriber.php b/src/Validator/UpdateVersionValidator.php similarity index 94% rename from src/Event/UpdateVersionSubscriber.php rename to src/Validator/UpdateVersionValidator.php index a8687ae3a7c07848a86dbca3ee31971f8783b743..bbbcc5f8ef7dd59a59733757c6b0bf6d598818e8 100644 --- a/src/Event/UpdateVersionSubscriber.php +++ b/src/Validator/UpdateVersionValidator.php @@ -1,8 +1,9 @@ <?php -namespace Drupal\automatic_updates\Event; +namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\AutomaticUpdatesEvents; +use Drupal\automatic_updates\Event\PreStartEvent; use Drupal\automatic_updates\Updater; use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\Core\Extension\ExtensionVersion; @@ -12,7 +13,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Validates that core updates are within a supported version range. */ -class UpdateVersionSubscriber implements EventSubscriberInterface { +class UpdateVersionValidator implements EventSubscriberInterface { use StringTranslationTrait; diff --git a/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php b/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php index 7426323fc4674b270458e6d78e73fb3992685082..2ad27ce9ed4eaa4401507b3902a827a440aebf8d 100644 --- a/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php @@ -9,7 +9,7 @@ use PhpTuf\ComposerStager\Exception\IOException; use PhpTuf\ComposerStager\Infrastructure\Process\ExecutableFinderInterface; /** - * @covers \Drupal\automatic_updates\Validation\ComposerExecutableValidator + * @covers \Drupal\automatic_updates\Validator\ComposerExecutableValidator * * @group automatic_updates */ diff --git a/tests/src/Unit/StagedProjectsValidationTest.php b/tests/src/Unit/StagedProjectsValidatorTest.php similarity index 91% rename from tests/src/Unit/StagedProjectsValidationTest.php rename to tests/src/Unit/StagedProjectsValidatorTest.php index a746e6708f9c6c63d665c279603f6e270362b8f3..026e48e2078dcb12d68144c4c63fe057c6632cc3 100644 --- a/tests/src/Unit/StagedProjectsValidationTest.php +++ b/tests/src/Unit/StagedProjectsValidatorTest.php @@ -4,7 +4,7 @@ namespace Drupal\Tests\automatic_updates\Unit; use Drupal\automatic_updates\Event\UpdateEvent; use Drupal\automatic_updates\Updater; -use Drupal\automatic_updates\Validation\StagedProjectsValidation; +use Drupal\automatic_updates\Validator\StagedProjectsValidator; use Drupal\Component\FileSystem\FileSystem; use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -12,11 +12,11 @@ use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Tests\UnitTestCase; /** - * @coversDefaultClass \Drupal\automatic_updates\Validation\StagedProjectsValidation + * @coversDefaultClass \Drupal\automatic_updates\Validator\StagedProjectsValidator * * @group automatic_updates */ -class StagedProjectsValidationTest extends UnitTestCase { +class StagedProjectsValidatorTest extends UnitTestCase { /** * Tests that if an exception is thrown, the update event will absorb it. @@ -29,7 +29,7 @@ class StagedProjectsValidationTest extends UnitTestCase { $updater = $this->prophesize(Updater::class); $updater->getActiveDirectory()->willReturn($active_dir); $updater->getStageDirectory()->willReturn($stage_dir); - $validator = new StagedProjectsValidation(new TestTranslationManager(), $updater->reveal()); + $validator = new StagedProjectsValidator(new TestTranslationManager(), $updater->reveal()); $event = new UpdateEvent(); $validator->validateStagedProjects($event); @@ -62,7 +62,7 @@ class StagedProjectsValidationTest extends UnitTestCase { $updater->getActiveDirectory()->willReturn("$fixtures_dir/active"); $updater->getStageDirectory()->willReturn("$fixtures_dir/staged"); - $validator = new StagedProjectsValidation(new TestTranslationManager(), $updater->reveal()); + $validator = new StagedProjectsValidator(new TestTranslationManager(), $updater->reveal()); $event = new UpdateEvent(); $validator->validateStagedProjects($event); $results = $event->getResults(); @@ -124,7 +124,7 @@ class StagedProjectsValidationTest extends UnitTestCase { $updater = $this->prophesize(Updater::class); $updater->getActiveDirectory()->willReturn("$fixtures_dir/active"); $updater->getStageDirectory()->willReturn("$fixtures_dir/staged"); - $validator = new StagedProjectsValidation(new TestTranslationManager(), $updater->reveal()); + $validator = new StagedProjectsValidator(new TestTranslationManager(), $updater->reveal()); $event = new UpdateEvent(); $validator->validateStagedProjects($event); $results = $event->getResults(); @@ -140,7 +140,7 @@ class StagedProjectsValidationTest extends UnitTestCase { $updater = $this->prophesize(Updater::class); $updater->getActiveDirectory()->willReturn("$fixtures_dir/active"); $updater->getStageDirectory()->willReturn("$fixtures_dir"); - $validator = new StagedProjectsValidation(new TestTranslationManager(), $updater->reveal()); + $validator = new StagedProjectsValidator(new TestTranslationManager(), $updater->reveal()); $event = new UpdateEvent(); $validator->validateStagedProjects($event); $results = $event->getResults();