From 0361e19bc49b61fee0fb893cc0be76be44c147b9 Mon Sep 17 00:00:00 2001 From: phenaproxima <phenaproxima@205645.no-reply.drupal.org> Date: Wed, 17 Nov 2021 19:36:29 +0000 Subject: [PATCH] Issue #3249983 by phenaproxima, tedbow: Create a test module in Package Manager for testing stage validation --- .../package_manager_test_validation.info.yml | 6 + ...ckage_manager_test_validation.services.yml | 7 + .../src/TestSubscriber.php | 127 ++++++++++++++++++ .../automatic_updates_test.info.yml | 1 + .../src/ReadinessChecker/TestChecker1.php | 75 +---------- .../Functional/ReadinessValidationTest.php | 29 ++-- tests/src/Functional/UpdaterFormTest.php | 9 +- .../ReadinessValidationManagerTest.php | 41 +++--- 8 files changed, 185 insertions(+), 110 deletions(-) create mode 100644 package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.info.yml create mode 100644 package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.services.yml create mode 100644 package_manager/tests/modules/package_manager_test_validation/src/TestSubscriber.php diff --git a/package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.info.yml b/package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.info.yml new file mode 100644 index 0000000000..c45c7abf8d --- /dev/null +++ b/package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.info.yml @@ -0,0 +1,6 @@ +name: 'Package Manager Validation Test' +description: 'Provides an event subscriber to test Package Manager validation.' +type: module +package: Testing +dependencies: + - automatic_updates:package_manager diff --git a/package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.services.yml b/package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.services.yml new file mode 100644 index 0000000000..6cd0f446bf --- /dev/null +++ b/package_manager/tests/modules/package_manager_test_validation/package_manager_test_validation.services.yml @@ -0,0 +1,7 @@ +services: + package_manager_test_validation.subscriber: + class: Drupal\package_manager_test_validation\TestSubscriber + arguments: + - '@state' + tags: + - { name: event_subscriber } diff --git a/package_manager/tests/modules/package_manager_test_validation/src/TestSubscriber.php b/package_manager/tests/modules/package_manager_test_validation/src/TestSubscriber.php new file mode 100644 index 0000000000..ffc6b59b10 --- /dev/null +++ b/package_manager/tests/modules/package_manager_test_validation/src/TestSubscriber.php @@ -0,0 +1,127 @@ +<?php + +namespace Drupal\package_manager_test_validation; + +use Drupal\Core\State\StateInterface; +use Drupal\package_manager\Event\PostApplyEvent; +use Drupal\package_manager\Event\PostCreateEvent; +use Drupal\package_manager\Event\PostDestroyEvent; +use Drupal\package_manager\Event\PostRequireEvent; +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 Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * Defines an event subscriber for testing validation of Package Manager events. + */ +class TestSubscriber implements EventSubscriberInterface { + + /** + * The key to use store the test results. + * + * @var string + */ + protected const STATE_KEY = 'package_manager_test_validation'; + + /** + * The state service. + * + * @var \Drupal\Core\State\StateInterface + */ + protected $state; + + /** + * Creates a TestSubscriber object. + * + * @param \Drupal\Core\State\StateInterface $state + * The state service. + */ + public function __construct(StateInterface $state) { + $this->state = $state; + } + + /** + * Sets validation results for a specific event. + * + * This method is static to enable setting the expected results before this + * module is enabled. + * + * @param \Drupal\package_manager\ValidationResult[]|null $results + * The validation results, or NULL to delete stored results. + * @param string $event + * The event class. + */ + public static function setTestResult(?array $results, string $event): void { + $key = static::STATE_KEY . '.' . $event; + + $state = \Drupal::state(); + if (isset($results)) { + $state->set($key, $results); + } + else { + $state->delete($key); + } + } + + /** + * Sets an exception to throw for a specific event. + * + * This method is static to enable setting the expected results before this + * module is enabled. + * + * @param \Throwable|null $error + * The exception to throw, or NULL to delete a stored exception. + * @param string $event + * The event class. + */ + public static function setException(?\Throwable $error, string $event): void { + $key = static::STATE_KEY . '.' . $event; + + $state = \Drupal::state(); + if (isset($error)) { + $state->set($key, $error); + } + else { + $state->delete($key); + } + } + + /** + * Adds validation results to a stage event. + * + * @param \Drupal\package_manager\Event\StageEvent $event + * The event object. + */ + public function addResults(StageEvent $event): void { + $results = $this->state->get(static::STATE_KEY . '.' . get_class($event), []); + + if ($results instanceof \Throwable) { + throw $results; + } + foreach ($results as $result) { + $event->addValidationResult($result); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $priority = defined('PACKAGE_MANAGER_TEST_VALIDATOR_PRIORITY') ? PACKAGE_MANAGER_TEST_VALIDATOR_PRIORITY : 5; + + return [ + PreCreateEvent::class => ['addResults', $priority], + PostCreateEvent::class => ['addResults', $priority], + PreRequireEvent::class => ['addResults', $priority], + PostRequireEvent::class => ['addResults', $priority], + PreApplyEvent::class => ['addResults', $priority], + PostApplyEvent::class => ['addResults', $priority], + PreDestroyEvent::class => ['addResults', $priority], + PostDestroyEvent::class => ['addResults', $priority], + ]; + } + +} diff --git a/tests/modules/automatic_updates_test/automatic_updates_test.info.yml b/tests/modules/automatic_updates_test/automatic_updates_test.info.yml index ad42f727c2..3cb26fcffb 100644 --- a/tests/modules/automatic_updates_test/automatic_updates_test.info.yml +++ b/tests/modules/automatic_updates_test/automatic_updates_test.info.yml @@ -4,3 +4,4 @@ description: 'Module for testing Automatic Updates.' package: Testing dependencies: - drupal:automatic_updates + - automatic_updates:package_manager_test_validation diff --git a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php index c04f373d6c..ebcbb99d3c 100644 --- a/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php +++ b/tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php @@ -3,86 +3,19 @@ namespace Drupal\automatic_updates_test\ReadinessChecker; use Drupal\automatic_updates\Event\ReadinessCheckEvent; -use Drupal\Core\State\StateInterface; -use Drupal\package_manager\Event\PreApplyEvent; -use Drupal\package_manager\Event\PreCreateEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Drupal\package_manager_test_validation\TestSubscriber; /** * A test readiness checker. */ -class TestChecker1 implements EventSubscriberInterface { - - /** - * The key to use store the test results. - */ - protected const STATE_KEY = 'automatic_updates_test.checker_results'; - - /** - * The state service. - * - * @var \Drupal\Core\State\StateInterface - */ - protected $state; - - /** - * Creates a TestChecker object. - * - * @param \Drupal\Core\State\StateInterface $state - * The state service. - */ - public function __construct(StateInterface $state) { - $this->state = $state; - } - - /** - * Sets messages for this readiness checker. - * - * This method is static to enable setting the expected messages before the - * test module is enabled. - * - * @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 - * (optional )The event name. Defaults to - * ReadinessCheckEvent::class. - */ - public static function setTestResult($checker_results, string $event_name = ReadinessCheckEvent::class): void { - $key = static::STATE_KEY . ".$event_name"; - - if (isset($checker_results)) { - \Drupal::state()->set($key, $checker_results); - } - else { - \Drupal::state()->delete($key); - } - } - - /** - * Adds test result to an update event from a state setting. - * - * @param object $event - * The update event. - */ - public function addResults(object $event): void { - $results = $this->state->get(static::STATE_KEY . '.' . get_class($event), []); - if ($results instanceof \Throwable) { - throw $results; - } - foreach ($results as $result) { - $event->addValidationResult($result); - } - } +class TestChecker1 extends TestSubscriber { /** * {@inheritdoc} */ public static function getSubscribedEvents() { - $priority = defined('AUTOMATIC_UPDATES_TEST_SET_PRIORITY') ? AUTOMATIC_UPDATES_TEST_SET_PRIORITY : 5; - $events[ReadinessCheckEvent::class][] = ['addResults', $priority]; - $events[PreCreateEvent::class][] = ['addResults', $priority]; - $events[PreApplyEvent::class][] = ['addResults', $priority]; + $events = parent::getSubscribedEvents(); + $events[ReadinessCheckEvent::class] = reset($events); return $events; } diff --git a/tests/src/Functional/ReadinessValidationTest.php b/tests/src/Functional/ReadinessValidationTest.php index 2db68bf4c7..9adf4e0fc7 100644 --- a/tests/src/Functional/ReadinessValidationTest.php +++ b/tests/src/Functional/ReadinessValidationTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\automatic_updates\Functional; use Behat\Mink\Element\NodeElement; +use Drupal\automatic_updates\Event\ReadinessCheckEvent; use Drupal\automatic_updates_test\Datetime\TestTime; use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1; use Drupal\automatic_updates_test2\ReadinessChecker\TestChecker2; @@ -115,7 +116,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $this->assertNoErrors(TRUE); /** @var \Drupal\package_manager\ValidationResult[] $expected_results */ $expected_results = $this->testResults['checker_1']['1 error']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); // Run the readiness checks. $this->clickLink('Run readiness checks'); @@ -136,7 +137,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $this->assertErrors($expected_results); $expected_results = $this->testResults['checker_1']['1 error 1 warning']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $key_value->delete('readiness_validation_last_run'); // Confirm a new message is displayed if the stored messages are deleted. $this->drupalGet('admin/reports/status'); @@ -149,7 +150,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $key_value->delete('readiness_validation_last_run'); $expected_results = $this->testResults['checker_1']['2 errors 2 warnings']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $this->drupalGet('admin/reports/status'); // Confirm that both messages and summaries will be displayed on status // report when there multiple messages. @@ -158,7 +159,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $key_value->delete('readiness_validation_last_run'); $expected_results = $this->testResults['checker_1']['2 warnings']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $this->drupalGet('admin/reports/status'); $assert->pageTextContainsOnce('Update readiness checks'); // Confirm that warnings will display on the status report if there are no @@ -167,7 +168,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $key_value->delete('readiness_validation_last_run'); $expected_results = $this->testResults['checker_1']['1 warning']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $this->drupalGet('admin/reports/status'); $assert->pageTextContainsOnce('Update readiness checks'); $this->assertWarnings($expected_results); @@ -196,7 +197,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { // Confirm a user without the permission to run readiness checks does not // have a link to run the checks when the checks need to be run again. $expected_results = $this->testResults['checker_1']['1 error']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); // @todo Change this to use ::delayRequestTime() to simulate running cron // after a 24 wait instead of directly deleting 'readiness_validation_last_run' // https://www.drupal.org/node/3113971. @@ -219,7 +220,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $assert->pageTextContainsOnce($expected_results[0]->getMessages()[0]); $expected_results = $this->testResults['checker_1']['1 error 1 warning']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); // Confirm a new message is displayed if the cron is run after an hour. $this->delayRequestTime(); $this->cronRun(); @@ -238,7 +239,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { // Confirm that if cron runs less than hour after it previously ran it will // not run the checkers again. $unexpected_results = $this->testResults['checker_1']['2 errors 2 warnings']; - TestChecker1::setTestResult($unexpected_results); + TestChecker1::setTestResult($unexpected_results, ReadinessCheckEvent::class); $this->delayRequestTime(30); $this->cronRun(); $this->drupalGet('admin/structure'); @@ -267,7 +268,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $assert->pageTextNotContains($expected_results['1:warnings']->getSummary()); $expected_results = $this->testResults['checker_1']['2 warnings']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $this->delayRequestTime(); $this->cronRun(); $this->drupalGet('admin/structure'); @@ -281,7 +282,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $assert->pageTextContainsOnce($expected_results[0]->getSummary()); $expected_results = $this->testResults['checker_1']['1 warning']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $this->delayRequestTime(); $this->cronRun(); $this->drupalGet('admin/structure'); @@ -311,7 +312,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $this->assertNoErrors(TRUE); $expected_results = $this->testResults['checker_1']['1 error']; - TestChecker2::setTestResult($expected_results); + TestChecker2::setTestResult($expected_results, ReadinessCheckEvent::class); $this->container->get('module_installer')->install(['automatic_updates_test2']); $this->drupalGet('admin/structure'); $assert->pageTextContainsOnce($expected_results[0]->getMessages()[0]); @@ -319,7 +320,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { // Confirm that installing a module that does not provide a new checker does // not run the checkers on install. $unexpected_results = $this->testResults['checker_1']['2 errors 2 warnings']; - TestChecker2::setTestResult($unexpected_results); + TestChecker2::setTestResult($unexpected_results, ReadinessCheckEvent::class); $this->container->get('module_installer')->install(['help']); // Check for message on 'admin/structure' instead of the status report // because checkers will be run if needed on the status report. @@ -339,9 +340,9 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase { $this->drupalLogin($this->checkerRunnerUser); $expected_results_1 = $this->testResults['checker_1']['1 error']; - TestChecker1::setTestResult($expected_results_1); + TestChecker1::setTestResult($expected_results_1, ReadinessCheckEvent::class); $expected_results_2 = $this->testResults['checker_2']['1 error']; - TestChecker2::setTestResult($expected_results_2); + TestChecker2::setTestResult($expected_results_2, ReadinessCheckEvent::class); $this->container->get('module_installer')->install([ 'automatic_updates', 'automatic_updates_test', diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index f05a955fcf..ca4129770d 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\automatic_updates\Functional; +use Drupal\automatic_updates\Event\ReadinessCheckEvent; use Drupal\automatic_updates\Exception\UpdateException; use Drupal\package_manager\Event\PreCreateEvent; use Drupal\package_manager\ValidationResult; @@ -143,7 +144,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { // Store a fake readiness error, which will be cached. $message = t("You've not experienced Shakespeare until you have read him in the original Klingon."); $error = ValidationResult::createError([$message]); - TestChecker1::setTestResult([$error]); + TestChecker1::setTestResult([$error], ReadinessCheckEvent::class); $this->drupalGet('/admin/reports/status'); $page->clickLink('Run readiness checks'); @@ -158,7 +159,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { // Set up a new fake error. $this->createTestValidationResults(); $expected_results = $this->testResults['checker_1']['1 error']; - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); // If a validator raises an error during readiness checking, the form should // not have a submit button. @@ -172,12 +173,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $assert_session->pageTextContainsOnce(static::$errorsExplanation); $assert_session->pageTextNotContains(static::$warningsExplanation); $assert_session->pageTextNotContains((string) $message); - TestChecker1::setTestResult(NULL); + TestChecker1::setTestResult(NULL, ReadinessCheckEvent::class); // Repackage the validation error as an exception, so we can test what // happens if a validator throws once the update has started. $error = new UpdateException($expected_results, 'The update exploded.'); - TestChecker1::setTestResult($error, PreCreateEvent::class); + TestChecker1::setException($error, PreCreateEvent::class); $session->reload(); $assert_session->pageTextNotContains(static::$errorsExplanation); $assert_session->pageTextNotContains(static::$warningsExplanation); diff --git a/tests/src/Kernel/ReadinessValidation/ReadinessValidationManagerTest.php b/tests/src/Kernel/ReadinessValidation/ReadinessValidationManagerTest.php index cda7c9a149..c45e4a11dd 100644 --- a/tests/src/Kernel/ReadinessValidation/ReadinessValidationManagerTest.php +++ b/tests/src/Kernel/ReadinessValidation/ReadinessValidationManagerTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation; +use Drupal\automatic_updates\Event\ReadinessCheckEvent; use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1; use Drupal\automatic_updates_test2\ReadinessChecker\TestChecker2; use Drupal\system\SystemManager; @@ -44,15 +45,14 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { array_pop($this->testResults['checker_1']), array_pop($this->testResults['checker_2']), ]; - TestChecker1::setTestResult($expected_results[0]); - TestChecker2::setTestResult($expected_results[1]); + TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class); + TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class); $expected_results_all = array_merge($expected_results[0], $expected_results[1]); $this->assertCheckerResultsFromManager($expected_results_all, TRUE); // Define a constant flag that will cause the readiness checker // service priority to be altered. - // @see \Drupal\automatic_updates_test\AutoUpdatesTestServiceProvider::alter(). - define('AUTOMATIC_UPDATES_TEST_SET_PRIORITY', 1); + define('PACKAGE_MANAGER_TEST_VALIDATOR_PRIORITY', 1); // Rebuild the container to trigger the service to be altered. $kernel = $this->container->get('kernel'); $this->container = $kernel->rebuildContainer(); @@ -67,8 +67,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { $this->testResults['checker_1']['2 errors 2 warnings'], $this->testResults['checker_2']['2 errors 2 warnings'], ]; - TestChecker1::setTestResult($expected_results[0]); - TestChecker2::setTestResult($expected_results[1]); + TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class); + TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class); $expected_results_all = array_merge($expected_results[1], $expected_results[0]); $this->assertCheckerResultsFromManager($expected_results_all, TRUE); @@ -91,7 +91,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { */ public function testRunOnInstall(): void { $expected_results = [array_pop($this->testResults['checker_1'])]; - TestChecker1::setTestResult($expected_results[0]); + TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class); // Confirm that messages from an existing module are displayed when // 'automatic_updates' is installed. $this->container->get('module_installer')->install(['automatic_updates']); @@ -103,8 +103,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { array_pop($this->testResults['checker_1']), array_pop($this->testResults['checker_2']), ]; - TestChecker1::setTestResult($expected_results[0]); - TestChecker2::setTestResult($expected_results[1]); + TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class); + TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class); $this->container->get('module_installer')->install(['automatic_updates_test2']); $expected_results_all = array_merge($expected_results[0], $expected_results[1]); $this->assertCheckerResultsFromManager($expected_results_all); @@ -115,8 +115,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { array_pop($this->testResults['checker_1']), array_pop($this->testResults['checker_2']), ]; - TestChecker1::setTestResult($unexpected_results[0]); - TestChecker2::setTestResult($unexpected_results[1]); + TestChecker1::setTestResult($unexpected_results[0], ReadinessCheckEvent::class); + TestChecker2::setTestResult($unexpected_results[1], ReadinessCheckEvent::class); $this->container->get('module_installer')->install(['help']); $this->assertCheckerResultsFromManager($expected_results_all); } @@ -129,8 +129,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { array_pop($this->testResults['checker_1']), array_pop($this->testResults['checker_2']), ]; - TestChecker1::setTestResult($expected_results[0]); - TestChecker2::setTestResult($expected_results[1]); + TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class); + TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class); // Confirm that messages from existing modules are displayed when // 'automatic_updates' is installed. $this->container->get('module_installer')->install(['automatic_updates', 'automatic_updates_test2', 'help']); @@ -142,8 +142,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { $expected_results = [ array_pop($this->testResults['checker_1']), ]; - TestChecker1::setTestResult($expected_results[0]); - TestChecker2::setTestResult(array_pop($this->testResults['checker_2'])); + TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class); + TestChecker2::setTestResult(array_pop($this->testResults['checker_2']), ReadinessCheckEvent::class); $this->container->get('module_installer')->uninstall(['automatic_updates_test2']); $this->assertCheckerResultsFromManager($expected_results[0]); @@ -152,7 +152,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { $unexpected_results = [ array_pop($this->testResults['checker_1']), ]; - TestChecker1::setTestResult($unexpected_results[0]); + TestChecker1::setTestResult($unexpected_results[0], ReadinessCheckEvent::class); $this->container->get('module_installer')->uninstall(['help']); $this->assertCheckerResultsFromManager($expected_results[0]); } @@ -162,12 +162,12 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { */ public function testRunIfNeeded(): void { $expected_results = array_pop($this->testResults['checker_1']); - TestChecker1::setTestResult($expected_results); + TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class); $this->container->get('module_installer')->install(['automatic_updates', 'automatic_updates_test2']); $this->assertCheckerResultsFromManager($expected_results); $unexpected_results = array_pop($this->testResults['checker_1']); - TestChecker1::setTestResult($unexpected_results); + TestChecker1::setTestResult($unexpected_results, ReadinessCheckEvent::class); $manager = $this->container->get('automatic_updates.readiness_validation_manager'); // Confirm that the new results will not be returned because the checkers // will not be run. @@ -185,7 +185,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { // Confirm that the results are the same after rebuilding the container. $unexpected_results = array_pop($this->testResults['checker_1']); - TestChecker1::setTestResult($unexpected_results); + TestChecker1::setTestResult($unexpected_results, ReadinessCheckEvent::class); /** @var \Drupal\Core\DrupalKernel $kernel */ $kernel = $this->container->get('kernel'); $this->container = $kernel->rebuildContainer(); @@ -197,8 +197,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { // higher than 'automatic_updates_test2.checker' which has a priority of 3. // Because the list of checker IDs is not identical to the previous checker // run runIfNoStoredValidResults() will run the checkers again. - // @see \Drupal\automatic_updates_test\AutoUpdatesTestServiceProvider::alter(). - define('AUTOMATIC_UPDATES_TEST_SET_PRIORITY', 1); + define('PACKAGE_MANAGER_TEST_VALIDATOR_PRIORITY', 1); // Rebuild the container to trigger the readiness checker services to be // reordered. -- GitLab