diff --git a/package_manager/src/Event/StageEvent.php b/package_manager/src/Event/StageEvent.php index 2aeadbf8103149db49187de2232ad8835a1317fc..e3fa57ee8c254d5a0d6266c2512b08261bd6cb83 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 8f4e9e16d277d07ab9ee1452d86ffa643c760080..a6fd0abd0a8f13d9d295402cd58f7b1169ffeaf6 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 0000000000000000000000000000000000000000..0ff99e55a92658bc674dbeca3ff77145c00769b9 --- /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 5e730a70b9bbd62fbb1210f023d98bc50f6456a0..7651548eddad405436595452917caaa1e1203d27 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 aba696089c610d3e4db645afabcfecbe417e8bf6..8124fb63e29098d8e449e6d9308686985b402937 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 cb4acd816c7d32466bdd4c4c96f9b1bd387e0f6d..aef519aabbbc10334adb618f9c9d8f2db36d0800 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 d1e8b75e4ca6454cc4ba972be26aa7462f1f5b30..b9b604ebcd5120e8d9f469c9b0b798e20e15bf2d 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 fb73fd5a84e8ea9a202089f24c0eaf25a6bc63a6..2e3fe7345234646e9a467ab16c666a4d93904875 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 2a5dd9042360a03f166ba0a97dd183024fc4808f..0a3c3a1a4d35a6bc7c6b4ae56ffa1c776ba56a80 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 700d0210a86928900d1c1c4ec0cc45294c161c63..95b02b39b32bfe687d6d4f42593612cbb93aa556 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 3b1858d582078e34fadbcbaa948b5aee4dc25184..b782d571cf1940ec8b242f978644cb57fd9baf7a 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 de6d63e3bde839a9a267c314d72459c2fffef811..bc891529be06549fe479665be14caf093107f02b 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 769203a42217ea30d55e147ce884618c75643890..1ae41cce3c82f7bd543857fb7cc88756fd483913 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 a824ab44fe204197b4a9e6dd8c0b3d194534631b..95b7d83af691ef0f7fe0690efd4efc83f39dca70 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 0417d7b5394546630d72d8607f62e665dd27a59f..6c786dfa9a4fa632b82d4eda997d2d6058bbb8fb 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 916b6f4be23bb6b1762544e9351dcafde81cbc3d..3fc71760d3b788fce58a89bd19e64ac783802600 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 16e2b42a4a1a9a7f66e8eb650a67ed4ea8319a69..2db68bf4c794bf064ffbe4023aeb3ce2e55a7792 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 a5c486492bbba96e411bbd460dd24c3e5a7f9fda..da3166bfe8f63c1dc87b658f8e195d48b62e4eb9 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 61bef3ff12248cc93f836b0f6b5c8a8134ed614a..2a389bfb707f49f45ffd8e857981876ea5f662f8 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 ceadb6b8c2fce5d35ab1c6607af9f9a3490fd405..bc54f88e7718f2fce39f458ceb0ec3a736776c4a 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 35753da2b2b88be6062dc584a2f35e05d7f609ed..7ce2d8c65f442c0960d91028a1bfbf4370398eb1 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 09deb352c6ca4ae5df232f5b36c947f779b2133b..c0ddd3b224f5b7fbf00dea0a4b39e9d02e081178 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 b98fb2027f22f87fc2a523565ec7d614ed65b3cb..4a1939d86084209bbdad65d65084abe6d4383e2e 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 a89547df21b4babfb0728430534689563dcf8b5f..8ff48a7af3526b5435d38d18597d4ee33f7fb24d 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 224b7c1e6b695c7dcf8c7fa46761c3e8fde98670..b7020c5ea7fd91eb3afbc1b78e766104961254d5 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 1662c64c65f6b23ee9b71ad83ee53b7570f972e1..69a32aa1fcd5b10d6bb314485734fd568ad2076f 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.