From 179e29e7f5f4fa6c1d04bdb72ce868d18e72c462 Mon Sep 17 00:00:00 2001 From: phenaproxima <phenaproxima@205645.no-reply.drupal.org> Date: Mon, 25 Oct 2021 19:58:09 +0000 Subject: [PATCH] Issue #3245810 by phenaproxima, tedbow: Move ValidationResult and related infrastructure into Package Manager --- package_manager/src/Event/StageEvent.php | 38 ++++++++++++ package_manager/src/Stage.php | 33 +++++++--- package_manager/src/StageException.php | 40 ++++++++++++ .../src}/ValidationResult.php | 2 +- .../tests/src/Kernel/StageEventsTest.php | 61 +++++++++++++++++++ src/Event/UpdateEvent.php | 8 +-- src/Exception/UpdateException.php | 6 +- src/Validation/ReadinessValidationManager.php | 4 +- src/Validator/ComposerExecutableValidator.php | 2 +- src/Validator/CoreComposerValidator.php | 2 +- src/Validator/DiskSpaceValidator.php | 2 +- src/Validator/PendingUpdatesValidator.php | 2 +- src/Validator/StagedProjectsValidator.php | 2 +- src/Validator/UpdateVersionValidator.php | 2 +- src/Validator/WritableFileSystemValidator.php | 2 +- .../src/ReadinessChecker/TestChecker1.php | 2 +- .../Functional/ReadinessValidationTest.php | 8 +-- tests/src/Functional/UpdaterFormTest.php | 2 +- .../ComposerExecutableValidatorTest.php | 4 +- .../CoreComposerValidatorTest.php | 2 +- .../DiskSpaceValidatorTest.php | 4 +- .../PendingUpdatesValidatorTest.php | 2 +- .../UpdateVersionValidatorTest.php | 2 +- .../WritableFileSystemValidatorTest.php | 2 +- tests/src/Traits/ValidationTestTrait.php | 12 ++-- tests/src/Unit/ValidationResultTest.php | 6 +- 26 files changed, 204 insertions(+), 48 deletions(-) create mode 100644 package_manager/src/StageException.php rename {src/Validation => package_manager/src}/ValidationResult.php (98%) diff --git a/package_manager/src/Event/StageEvent.php b/package_manager/src/Event/StageEvent.php index 2aeadbf810..e3fa57ee8c 100644 --- a/package_manager/src/Event/StageEvent.php +++ b/package_manager/src/Event/StageEvent.php @@ -2,10 +2,48 @@ namespace Drupal\package_manager\Event; +use Drupal\package_manager\ValidationResult; use Symfony\Contracts\EventDispatcher\Event; /** * Base class for all events related to the life cycle of the staging area. */ abstract class StageEvent extends Event { + + /** + * The validation results. + * + * @var \Drupal\package_manager\ValidationResult[] + */ + protected $results = []; + + /** + * Gets the validation results. + * + * @param int|null $severity + * (optional) The severity for the results to return. Should be one of the + * SystemManager::REQUIREMENT_* constants. + * + * @return \Drupal\package_manager\ValidationResult[] + * The validation results. + */ + public function getResults(?int $severity = NULL): array { + if ($severity !== NULL) { + return array_filter($this->results, function ($result) use ($severity) { + return $result->getSeverity() === $severity; + }); + } + return $this->results; + } + + /** + * Adds a validation result. + * + * @param \Drupal\package_manager\ValidationResult $validation_result + * The validation result. + */ + public function addValidationResult(ValidationResult $validation_result): void { + $this->results[] = $validation_result; + } + } diff --git a/package_manager/src/Stage.php b/package_manager/src/Stage.php index 8f4e9e16d2..a6fd0abd0a 100644 --- a/package_manager/src/Stage.php +++ b/package_manager/src/Stage.php @@ -10,6 +10,8 @@ use Drupal\package_manager\Event\PreApplyEvent; use Drupal\package_manager\Event\PreCreateEvent; use Drupal\package_manager\Event\PreDestroyEvent; use Drupal\package_manager\Event\PreRequireEvent; +use Drupal\package_manager\Event\StageEvent; +use Drupal\system\SystemManager; use PhpTuf\ComposerStager\Domain\BeginnerInterface; use PhpTuf\ComposerStager\Domain\CleanerInterface; use PhpTuf\ComposerStager\Domain\CommitterInterface; @@ -105,9 +107,9 @@ class Stage { $active_dir = $this->pathLocator->getActiveDirectory(); $stage_dir = $this->pathLocator->getStageDirectory(); - $this->eventDispatcher->dispatch(new PreCreateEvent()); + $this->dispatch(new PreCreateEvent()); $this->beginner->begin($active_dir, $stage_dir, $exclusions); - $this->eventDispatcher->dispatch(new PostCreateEvent()); + $this->dispatch(new PostCreateEvent()); } /** @@ -120,9 +122,9 @@ class Stage { $command = array_merge(['require'], $constraints); $command[] = '--update-with-all-dependencies'; - $this->eventDispatcher->dispatch(new PreRequireEvent()); + $this->dispatch(new PreRequireEvent()); $this->stager->stage($command, $this->pathLocator->getStageDirectory()); - $this->eventDispatcher->dispatch(new PostRequireEvent()); + $this->dispatch(new PostRequireEvent()); } /** @@ -137,21 +139,36 @@ class Stage { $active_dir = $this->pathLocator->getActiveDirectory(); $stage_dir = $this->pathLocator->getStageDirectory(); - $this->eventDispatcher->dispatch(new PreApplyEvent()); + $this->dispatch(new PreApplyEvent()); $this->committer->commit($stage_dir, $active_dir, $exclusions); - $this->eventDispatcher->dispatch(new PostApplyEvent()); + $this->dispatch(new PostApplyEvent()); } /** * Deletes the staging area. */ public function destroy(): void { - $this->eventDispatcher->dispatch(new PreDestroyEvent()); + $this->dispatch(new PreDestroyEvent()); $stage_dir = $this->pathLocator->getStageDirectory(); if (is_dir($stage_dir)) { $this->cleaner->clean($stage_dir); } - $this->eventDispatcher->dispatch(new PostDestroyEvent()); + $this->dispatch(new PostDestroyEvent()); + } + + /** + * Dispatches an event and handles any errors that it collects. + * + * @param \Drupal\package_manager\Event\StageEvent $event + * The event object. + */ + protected function dispatch(StageEvent $event): void { + $this->eventDispatcher->dispatch($event); + + $errors = $event->getResults(SystemManager::REQUIREMENT_ERROR); + if ($errors) { + throw new StageException($errors); + } } } diff --git a/package_manager/src/StageException.php b/package_manager/src/StageException.php new file mode 100644 index 0000000000..0ff99e55a9 --- /dev/null +++ b/package_manager/src/StageException.php @@ -0,0 +1,40 @@ +<?php + +namespace Drupal\package_manager; + +/** + * Exception thrown when the staging area encounters an error condition. + */ +class StageException extends \RuntimeException { + + /** + * Any relevant validation results. + * + * @var \Drupal\package_manager\ValidationResult[] + */ + protected $results = []; + + /** + * Constructs a StageException object. + * + * @param \Drupal\package_manager\ValidationResult[] $results + * Any relevant validation results. + * @param mixed ...$arguments + * Arguments to pass to the parent constructor. + */ + public function __construct(array $results = [], ...$arguments) { + $this->results = $results; + parent::__construct(...$arguments); + } + + /** + * Gets the validation results. + * + * @return \Drupal\package_manager\ValidationResult[] + * The validation results. + */ + public function getResults(): array { + return $this->results; + } + +} diff --git a/src/Validation/ValidationResult.php b/package_manager/src/ValidationResult.php similarity index 98% rename from src/Validation/ValidationResult.php rename to package_manager/src/ValidationResult.php index 5e730a70b9..7651548edd 100644 --- a/src/Validation/ValidationResult.php +++ b/package_manager/src/ValidationResult.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\automatic_updates\Validation; +namespace Drupal\package_manager; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\system\SystemManager; diff --git a/package_manager/tests/src/Kernel/StageEventsTest.php b/package_manager/tests/src/Kernel/StageEventsTest.php index aba696089c..8124fb63e2 100644 --- a/package_manager/tests/src/Kernel/StageEventsTest.php +++ b/package_manager/tests/src/Kernel/StageEventsTest.php @@ -12,6 +12,8 @@ use Drupal\package_manager\Event\PreCreateEvent; use Drupal\package_manager\Event\PreDestroyEvent; use Drupal\package_manager\Event\PreRequireEvent; use Drupal\package_manager\Event\StageEvent; +use Drupal\package_manager\StageException; +use Drupal\package_manager\ValidationResult; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -60,6 +62,12 @@ class StageEventsTest extends KernelTestBase implements EventSubscriberInterface */ public function handleEvent(StageEvent $event): void { array_push($this->events, get_class($event)); + + // Adding a warning to the event, should not trigger an exception. + $result = ValidationResult::createWarning([ + 'This is a public service announcement, this is only a test.', + ]); + $event->addValidationResult($result); } /** @@ -86,4 +94,57 @@ class StageEventsTest extends KernelTestBase implements EventSubscriberInterface ]); } + /** + * Data provider for ::testError(). + * + * @return string[][] + * Sets of arguments to pass to the test method. + */ + public function providerError(): array { + return [ + [PreCreateEvent::class], + [PostCreateEvent::class], + [PreRequireEvent::class], + [PostRequireEvent::class], + [PreApplyEvent::class], + [PostApplyEvent::class], + [PreDestroyEvent::class], + [PostDestroyEvent::class], + ]; + } + + /** + * Tests that an exception is thrown if an event collects an error. + * + * @param string $event_class + * The event class to test. + * + * @dataProvider providerError + */ + public function testError(string $event_class): void { + // Set up an event listener which will only flag an error for the event + // class under test. + $handler = function (StageEvent $event) use ($event_class): void { + if (get_class($event) === $event_class) { + $result = ValidationResult::createError(['Burn, baby, burn']); + $event->addValidationResult($result); + } + }; + $this->container->get('event_dispatcher') + ->addListener($event_class, $handler); + + try { + $stage = $this->container->get('package_manager.stage'); + $stage->create(); + $stage->require(['ext-json:*']); + $stage->apply(); + $stage->destroy(); + + $this->fail('Expected \Drupal\package_manager\StageException to be thrown.'); + } + catch (StageException $e) { + $this->assertCount(1, $e->getResults()); + } + } + } diff --git a/src/Event/UpdateEvent.php b/src/Event/UpdateEvent.php index cb4acd816c..aef519aabb 100644 --- a/src/Event/UpdateEvent.php +++ b/src/Event/UpdateEvent.php @@ -2,9 +2,9 @@ namespace Drupal\automatic_updates\Event; -use Drupal\automatic_updates\Validation\ValidationResult; use Drupal\Component\EventDispatcher\Event; use Drupal\package_manager\ComposerUtility; +use Drupal\package_manager\ValidationResult; /** * Event fired when a site is updating. @@ -19,7 +19,7 @@ abstract class UpdateEvent extends Event { /** * The validation results. * - * @var \Drupal\automatic_updates\Validation\ValidationResult[] + * @var \Drupal\package_manager\ValidationResult[] */ protected $results = []; @@ -53,7 +53,7 @@ abstract class UpdateEvent extends Event { /** * Adds a validation result. * - * @param \Drupal\automatic_updates\Validation\ValidationResult $validation_result + * @param \Drupal\package_manager\ValidationResult $validation_result * The validation result. */ public function addValidationResult(ValidationResult $validation_result): void { @@ -67,7 +67,7 @@ abstract class UpdateEvent extends Event { * (optional) The severity for the results to return. Should be one of the * SystemManager::REQUIREMENT_* constants. * - * @return \Drupal\automatic_updates\Validation\ValidationResult[] + * @return \Drupal\package_manager\ValidationResult[] * The validation results. */ public function getResults(?int $severity = NULL): array { diff --git a/src/Exception/UpdateException.php b/src/Exception/UpdateException.php index d1e8b75e4c..b9b604ebcd 100644 --- a/src/Exception/UpdateException.php +++ b/src/Exception/UpdateException.php @@ -10,14 +10,14 @@ class UpdateException extends \RuntimeException { /** * The validation results for the exception. * - * @var \Drupal\automatic_updates\Validation\ValidationResult[] + * @var \Drupal\package_manager\ValidationResult[] */ protected $validationResults; /** * Constructs an UpdateException object. * - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $validation_results + * @param \Drupal\package_manager\ValidationResult[] $validation_results * The validation results. * @param string $message * The exception message. @@ -30,7 +30,7 @@ class UpdateException extends \RuntimeException { /** * Gets the validation results for the exception. * - * @return \Drupal\automatic_updates\Validation\ValidationResult[] + * @return \Drupal\package_manager\ValidationResult[] * The validation results. */ public function getValidationResults(): array { diff --git a/src/Validation/ReadinessValidationManager.php b/src/Validation/ReadinessValidationManager.php index fb73fd5a84..2e3fe73452 100644 --- a/src/Validation/ReadinessValidationManager.php +++ b/src/Validation/ReadinessValidationManager.php @@ -146,7 +146,7 @@ class ReadinessValidationManager { * (optional) The severity for the results to return. Should be one of the * SystemManager::REQUIREMENT_* constants. * - * @return \Drupal\automatic_updates\Validation\ValidationResult[]| + * @return \Drupal\package_manager\ValidationResult[]| * The validation result objects or NULL if no results are * available or if the stored results are no longer valid. * @@ -172,7 +172,7 @@ class ReadinessValidationManager { * readiness check event are the same as the last time the event was * dispatched. * - * @return \Drupal\automatic_updates\Validation\ValidationResult[]|null + * @return \Drupal\package_manager\ValidationResult[]|null * The stored results if available and still valid, otherwise null. */ protected function getStoredValidResults(): ?array { diff --git a/src/Validator/ComposerExecutableValidator.php b/src/Validator/ComposerExecutableValidator.php index 2a5dd90423..0a3c3a1a4d 100644 --- a/src/Validator/ComposerExecutableValidator.php +++ b/src/Validator/ComposerExecutableValidator.php @@ -4,7 +4,7 @@ namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\Event\ReadinessCheckEvent; use Drupal\automatic_updates\Event\UpdateEvent; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; diff --git a/src/Validator/CoreComposerValidator.php b/src/Validator/CoreComposerValidator.php index 700d0210a8..95b02b39b3 100644 --- a/src/Validator/CoreComposerValidator.php +++ b/src/Validator/CoreComposerValidator.php @@ -3,7 +3,7 @@ namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\Event\ReadinessCheckEvent; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\EventDispatcher\EventSubscriberInterface; diff --git a/src/Validator/DiskSpaceValidator.php b/src/Validator/DiskSpaceValidator.php index 3b1858d582..b782d571cf 100644 --- a/src/Validator/DiskSpaceValidator.php +++ b/src/Validator/DiskSpaceValidator.php @@ -4,7 +4,7 @@ namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\Event\ReadinessCheckEvent; use Drupal\automatic_updates\Event\UpdateEvent; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Component\FileSystem\FileSystem; use Drupal\Component\Utility\Bytes; use Drupal\Core\StringTranslation\StringTranslationTrait; diff --git a/src/Validator/PendingUpdatesValidator.php b/src/Validator/PendingUpdatesValidator.php index de6d63e3bd..bc891529be 100644 --- a/src/Validator/PendingUpdatesValidator.php +++ b/src/Validator/PendingUpdatesValidator.php @@ -5,7 +5,7 @@ namespace Drupal\automatic_updates\Validator; 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\package_manager\ValidationResult; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\Update\UpdateRegistry; diff --git a/src/Validator/StagedProjectsValidator.php b/src/Validator/StagedProjectsValidator.php index 769203a422..1ae41cce3c 100644 --- a/src/Validator/StagedProjectsValidator.php +++ b/src/Validator/StagedProjectsValidator.php @@ -3,7 +3,7 @@ namespace Drupal\automatic_updates\Validator; use Drupal\automatic_updates\Event\PreCommitEvent; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; diff --git a/src/Validator/UpdateVersionValidator.php b/src/Validator/UpdateVersionValidator.php index a824ab44fe..95b7d83af6 100644 --- a/src/Validator/UpdateVersionValidator.php +++ b/src/Validator/UpdateVersionValidator.php @@ -6,7 +6,7 @@ use Composer\Semver\Semver; 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\package_manager\ValidationResult; use Drupal\Core\Extension\ExtensionVersion; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; diff --git a/src/Validator/WritableFileSystemValidator.php b/src/Validator/WritableFileSystemValidator.php index 0417d7b539..6c786dfa9a 100644 --- a/src/Validator/WritableFileSystemValidator.php +++ b/src/Validator/WritableFileSystemValidator.php @@ -5,7 +5,7 @@ namespace Drupal\automatic_updates\Validator; 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\package_manager\ValidationResult; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\package_manager\PathLocator; diff --git a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php index 916b6f4be2..3fc71760d3 100644 --- a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php +++ b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php @@ -42,7 +42,7 @@ class TestChecker1 implements EventSubscriberInterface { * This method is static to enable setting the expected messages before the * test module is enabled. * - * @param \Drupal\automatic_updates\Validation\ValidationResult[]|\Throwable|null $checker_results + * @param \Drupal\package_manager\ValidationResult[]|\Throwable|null $checker_results * The test validation results, or an exception to throw, or NULL to delete * stored results. * @param string $event_name diff --git a/tests/src/Functional/ReadinessValidationTest.php b/tests/src/Functional/ReadinessValidationTest.php index 16e2b42a4a..2db68bf4c7 100644 --- a/tests/src/Functional/ReadinessValidationTest.php +++ b/tests/src/Functional/ReadinessValidationTest.php @@ -113,7 +113,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $this->drupalLogin($this->checkerRunnerUser); $this->drupalGet('admin/reports/status'); $this->assertNoErrors(TRUE); - /** @var \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results */ + /** @var \Drupal\package_manager\ValidationResult[] $expected_results */ $expected_results = $this->testResults['checker_1']['1 error']; TestChecker1::setTestResult($expected_results); @@ -382,7 +382,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { /** * Asserts that the displayed readiness requirement contains warnings. * - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The readiness check results that should be visible. * @param bool $run_link * (optional) Whether there should be a link to run the readiness checks. @@ -395,7 +395,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { /** * Asserts that the displayed readiness requirement contains errors. * - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The readiness check results that should be visible. * @param bool $run_link * (optional) Whether there should be a link to run the readiness checks. @@ -413,7 +413,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { * be. Can be one of 'error', 'warning', 'checked', or 'ok'. * @param string $preamble * The text that should appear before the result messages. - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The expected readiness check results, in the order we expect them to be * displayed. * @param bool $run_link diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index a5c486492b..da3166bfe8 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -4,7 +4,7 @@ namespace Drupal\Tests\automatic_updates\Functional; use Drupal\automatic_updates\Event\PreStartEvent; use Drupal\automatic_updates\Exception\UpdateException; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1; use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait; diff --git a/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php b/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php index 61bef3ff12..2a389bfb70 100644 --- a/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/ComposerExecutableValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\automatic_updates\Validator\ComposerExecutableValidator; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use PhpTuf\ComposerStager\Exception\IOException; @@ -111,7 +111,7 @@ class ComposerExecutableValidatorTest extends AutomaticUpdatesKernelTestBase { * * @param string $reported_version * The version of Composer that `composer --version` should report. - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The expected validation results. * * @dataProvider providerComposerVersionValidation diff --git a/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php b/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php index ceadb6b8c2..bc54f88e77 100644 --- a/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/CoreComposerValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\package_manager\PathLocator; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; diff --git a/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php b/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php index 35753da2b2..7ce2d8c65f 100644 --- a/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/DiskSpaceValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\automatic_updates\Validator\DiskSpaceValidator; use Drupal\Component\Utility\Bytes; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; @@ -145,7 +145,7 @@ class DiskSpaceValidatorTest extends AutomaticUpdatesKernelTestBase { * are the locations (only 'root', 'vendor', and 'temp' are supported), and * the values are the space that should be reported, in a format that can be * parsed by \Drupal\Component\Utility\Bytes::toNumber(). - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The expected validation results. * * @dataProvider providerDiskSpaceValidation diff --git a/tests/src/Kernel/ReadinessValidation/PendingUpdatesValidatorTest.php b/tests/src/Kernel/ReadinessValidation/PendingUpdatesValidatorTest.php index 09deb352c6..c0ddd3b224 100644 --- a/tests/src/Kernel/ReadinessValidation/PendingUpdatesValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/PendingUpdatesValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; /** diff --git a/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php b/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php index b98fb2027f..4a1939d860 100644 --- a/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/UpdateVersionValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; /** diff --git a/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php b/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php index a89547df21..8ff48a7af3 100644 --- a/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php +++ b/tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\automatic_updates\Validator\WritableFileSystemValidator; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\package_manager\PathLocator; diff --git a/tests/src/Traits/ValidationTestTrait.php b/tests/src/Traits/ValidationTestTrait.php index 224b7c1e6b..b7020c5ea7 100644 --- a/tests/src/Traits/ValidationTestTrait.php +++ b/tests/src/Traits/ValidationTestTrait.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\Traits; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; /** * Common methods for testing validation. @@ -26,7 +26,7 @@ trait ValidationTestTrait { /** * Test validation results. * - * @var \Drupal\automatic_updates\Validation\ValidationResult[][][] + * @var \Drupal\package_manager\ValidationResult[][][] */ protected $testResults; @@ -91,9 +91,9 @@ trait ValidationTestTrait { /** * Asserts two validation result sets are equal. * - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The expected validation results. - * @param \Drupal\automatic_updates\Validation\ValidationResult[]|null $actual_results + * @param \Drupal\package_manager\ValidationResult[]|null $actual_results * The actual validation results or NULL if known are available. */ protected function assertValidationResultsEqual(array $expected_results, array $actual_results): void { @@ -119,7 +119,7 @@ trait ValidationTestTrait { * (optional) The severity for the results to return. Should be one of the * SystemManager::REQUIREMENT_* constants. * - * @return \Drupal\automatic_updates\Validation\ValidationResult[]|null + * @return \Drupal\package_manager\ValidationResult[]|null * The messages of the type. */ protected function getResultsFromManager(bool $call_run = FALSE, ?int $severity = NULL): ?array { @@ -133,7 +133,7 @@ trait ValidationTestTrait { /** * Asserts expected validation results from the manager. * - * @param \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results + * @param \Drupal\package_manager\ValidationResult[] $expected_results * The expected results. * @param bool $call_run * (Optional) Whether to call ::run() on the manager. Defaults to FALSE. diff --git a/tests/src/Unit/ValidationResultTest.php b/tests/src/Unit/ValidationResultTest.php index 1662c64c65..69a32aa1fc 100644 --- a/tests/src/Unit/ValidationResultTest.php +++ b/tests/src/Unit/ValidationResultTest.php @@ -2,13 +2,13 @@ namespace Drupal\Tests\automatic_updates\Unit; -use Drupal\automatic_updates\Validation\ValidationResult; +use Drupal\package_manager\ValidationResult; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\system\SystemManager; use Drupal\Tests\UnitTestCase; /** - * @coversDefaultClass \Drupal\automatic_updates\Validation\ValidationResult + * @coversDefaultClass \Drupal\package_manager\ValidationResult * * @group automatic_updates */ @@ -76,7 +76,7 @@ class ValidationResultTest extends UnitTestCase { /** * Asserts a check result is valid. * - * @param \Drupal\automatic_updates\Validation\ValidationResult $result + * @param \Drupal\package_manager\ValidationResult $result * The validation result to check. * @param array $expected_messages * The expected messages. -- GitLab