Skip to content
Snippets Groups Projects
Commit 9793f71c authored by Theresa Grannum's avatar Theresa Grannum Committed by Adam G-H
Browse files

Issue #3262284 by Theresa.Grannum: clean up...

Issue #3262284 by Theresa.Grannum: clean up package_manager_test_validation\TestSubscriber and classes that extend it
parent 88157d09
No related branches found
No related tags found
1 merge request!211Issue #3262284: clean up package_manager_test_validation\TestSubscriber and classes that extend it
Showing
with 73 additions and 73 deletions
services:
package_manager_test_validation.subscriber:
class: Drupal\package_manager_test_validation\TestSubscriber
class: Drupal\package_manager_test_validation\EventSubscriber\TestSubscriber
arguments:
- '@state'
tags:
......
<?php
namespace Drupal\package_manager_test_validation;
namespace Drupal\package_manager_test_validation\EventSubscriber;
use Drupal\Core\State\StateInterface;
use Drupal\package_manager\Event\PostApplyEvent;
......@@ -96,7 +96,7 @@ class TestSubscriber implements EventSubscriberInterface {
* @param \Drupal\package_manager\Event\StageEvent $event
* The event object.
*/
public function addResults(StageEvent $event): void {
public function handleEvent(StageEvent $event): void {
$results = $this->state->get(static::STATE_KEY . '.' . get_class($event), []);
if ($results instanceof \Throwable) {
......@@ -120,14 +120,14 @@ class TestSubscriber implements EventSubscriberInterface {
$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],
PreCreateEvent::class => ['handleEvent', $priority],
PostCreateEvent::class => ['handleEvent', $priority],
PreRequireEvent::class => ['handleEvent', $priority],
PostRequireEvent::class => ['handleEvent', $priority],
PreApplyEvent::class => ['handleEvent', $priority],
PostApplyEvent::class => ['handleEvent', $priority],
PreDestroyEvent::class => ['handleEvent', $priority],
PostDestroyEvent::class => ['handleEvent', $priority],
];
}
......
......@@ -8,7 +8,7 @@ use Drupal\package_manager\Event\PostDestroyEvent;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Exception\StageException;
use Drupal\package_manager\Exception\StageOwnershipException;
use Drupal\package_manager_test_validation\TestSubscriber;
use Drupal\package_manager_test_validation\EventSubscriber\TestSubscriber;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Prophecy\Argument;
use Psr\Log\LoggerInterface;
......
......@@ -4,7 +4,7 @@ services:
tags:
- { name: event_subscriber }
automatic_updates_test.checker:
class: Drupal\automatic_updates_test\ReadinessChecker\TestChecker1
class: Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1
tags:
- { name: event_subscriber }
arguments: ['@state']
......
<?php
namespace Drupal\automatic_updates_test\ReadinessChecker;
namespace Drupal\automatic_updates_test\EventSubscriber;
use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\package_manager_test_validation\TestSubscriber;
use Drupal\package_manager_test_validation\EventSubscriber\TestSubscriber;
/**
* A test readiness checker.
*/
class TestChecker1 extends TestSubscriber {
class TestSubscriber1 extends TestSubscriber {
/**
* {@inheritdoc}
......
services:
automatic_updates_test2.checker:
class: Drupal\automatic_updates_test2\ReadinessChecker\TestChecker2
class: Drupal\automatic_updates_test2\EventSubscriber\TestSubscriber2
tags:
- { name: event_subscriber }
arguments: ['@state']
<?php
namespace Drupal\automatic_updates_test2\ReadinessChecker;
namespace Drupal\automatic_updates_test2\EventSubscriber;
use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1;
use Drupal\package_manager\Event\PreCreateEvent;
/**
* A test readiness checker.
*/
class TestChecker2 extends TestChecker1 {
class TestSubscriber2 extends TestSubscriber1 {
protected const STATE_KEY = 'automatic_updates_test2.checker_results';
public static function getSubscribedEvents() {
$events[ReadinessCheckEvent::class][] = ['addResults', 4];
$events[PreCreateEvent::class][] = ['addResults', 4];
$events[ReadinessCheckEvent::class][] = ['handleEvent', 4];
$events[PreCreateEvent::class][] = ['handleEvent', 4];
return $events;
}
......
......@@ -5,8 +5,8 @@ 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;
use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1;
use Drupal\automatic_updates_test2\EventSubscriber\TestSubscriber2;
use Drupal\system\SystemManager;
use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait;
use Drupal\Tests\Traits\Core\CronRunTrait;
......@@ -43,7 +43,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
/**
* The test checker.
*
* @var \Drupal\automatic_updates_test\ReadinessChecker\TestChecker1
* @var \Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1
*/
protected $testChecker;
......@@ -114,7 +114,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, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
// Run the readiness checks.
$this->clickLink('Run readiness checks');
......@@ -135,7 +135,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertErrors($expected_results);
$expected_results = $this->testResults['checker_1']['1 error 1 warning'];
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::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');
......@@ -148,7 +148,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, ReadinessCheckEvent::class);
TestSubscriber1::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.
......@@ -157,7 +157,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$key_value->delete('readiness_validation_last_run');
$expected_results = $this->testResults['checker_1']['2 warnings'];
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::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
......@@ -166,7 +166,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$key_value->delete('readiness_validation_last_run');
$expected_results = $this->testResults['checker_1']['1 warning'];
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
$this->drupalGet('admin/reports/status');
$assert->pageTextContainsOnce('Update readiness checks');
$this->assertWarnings($expected_results);
......@@ -195,7 +195,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, ReadinessCheckEvent::class);
TestSubscriber1::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.
......@@ -218,7 +218,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, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
// Confirm a new message is displayed if the cron is run after an hour.
$this->delayRequestTime();
$this->cronRun();
......@@ -237,7 +237,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, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($unexpected_results, ReadinessCheckEvent::class);
$this->delayRequestTime(30);
$this->cronRun();
$this->drupalGet('admin/structure');
......@@ -266,7 +266,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$assert->pageTextNotContains($expected_results['1:warnings']->getSummary());
$expected_results = $this->testResults['checker_1']['2 warnings'];
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
$this->delayRequestTime();
$this->cronRun();
$this->drupalGet('admin/structure');
......@@ -280,7 +280,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$assert->pageTextContainsOnce($expected_results[0]->getSummary());
$expected_results = $this->testResults['checker_1']['1 warning'];
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
$this->delayRequestTime();
$this->cronRun();
$this->drupalGet('admin/structure');
......@@ -310,7 +310,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertNoErrors(TRUE);
$expected_results = $this->testResults['checker_1']['1 error'];
TestChecker2::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber2::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 +319,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
// module does not provide any validators.
$previous_results = $expected_results;
$expected_results = $this->testResults['checker_1']['2 errors 2 warnings'];
TestChecker2::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber2::setTestResult($expected_results, ReadinessCheckEvent::class);
$this->container->get('module_installer')->install(['help']);
// Check for messages on 'admin/structure' instead of the status report,
// because validators will be run if needed on the status report.
......@@ -338,9 +338,9 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
$this->drupalLogin($this->checkerRunnerUser);
$expected_results_1 = $this->testResults['checker_1']['1 error'];
TestChecker1::setTestResult($expected_results_1, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results_1, ReadinessCheckEvent::class);
$expected_results_2 = $this->testResults['checker_2']['1 error'];
TestChecker2::setTestResult($expected_results_2, ReadinessCheckEvent::class);
TestSubscriber2::setTestResult($expected_results_2, ReadinessCheckEvent::class);
$this->container->get('module_installer')->install([
'automatic_updates',
'automatic_updates_test',
......@@ -381,7 +381,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
// Flag a validation error, which will be displayed in the messages area.
$results = $this->testResults['checker_1']['1 error'];
TestChecker1::setTestResult($results, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($results, ReadinessCheckEvent::class);
$message = $results[0]->getMessages()[0];
$this->container->get('module_installer')->install([
......@@ -398,7 +398,7 @@ class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
// flagging it.
$this->drupalGet('/admin/structure');
$assert_session->pageTextContains($message);
TestChecker1::setTestResult(NULL, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult(NULL, ReadinessCheckEvent::class);
$this->getSession()->reload();
$assert_session->pageTextContains($message);
......
......@@ -5,7 +5,7 @@ namespace Drupal\Tests\automatic_updates\Functional;
use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\ValidationResult;
use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1;
use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait;
use Drupal\Tests\package_manager\Traits\PackageManagerBypassTestTrait;
......@@ -151,7 +151,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], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult([$error], ReadinessCheckEvent::class);
$this->drupalGet('/admin/reports/status');
$page->clickLink('Run readiness checks');
......@@ -166,7 +166,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, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
// If a validator raises an error during readiness checking, the form should
// not have a submit button.
......@@ -180,11 +180,11 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$assert_session->pageTextContainsOnce(static::$errorsExplanation);
$assert_session->pageTextNotContains(static::$warningsExplanation);
$assert_session->pageTextNotContains((string) $message);
TestChecker1::setTestResult(NULL, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult(NULL, ReadinessCheckEvent::class);
// Make the validator throw an exception during pre-create.
$error = new \Exception('The update exploded.');
TestChecker1::setException($error, PreCreateEvent::class);
TestSubscriber1::setException($error, PreCreateEvent::class);
$session->reload();
$assert_session->pageTextNotContains(static::$errorsExplanation);
$assert_session->pageTextNotContains(static::$warningsExplanation);
......@@ -205,7 +205,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
// If a validator flags an error, but doesn't throw, the update should still
// be halted.
TestChecker1::setTestResult($expected_results, PreCreateEvent::class);
TestSubscriber1::setTestResult($expected_results, PreCreateEvent::class);
$page->pressButton('Update');
$this->checkForMetaRefresh();
$this->assertUpdateStagedTimes(0);
......@@ -301,7 +301,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
// on the updater form.
$this->createTestValidationResults();
$expected_results = $this->testResults['checker_1']['1 warning'];
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results, ReadinessCheckEvent::class);
$messages = reset($expected_results)->getMessages();
$page = $this->getSession()->getPage();
......
......@@ -3,7 +3,7 @@
namespace Drupal\Tests\automatic_updates\Kernel;
use Drupal\automatic_updates\CronUpdater;
use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1;
use Drupal\Core\Form\FormState;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\package_manager\Event\PostApplyEvent;
......@@ -290,14 +290,14 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
$results = [
ValidationResult::createError(['Destroy the stage!']),
];
TestChecker1::setTestResult($results, $event_class);
TestSubscriber1::setTestResult($results, $event_class);
$exception = new StageValidationException($results, 'Unable to complete the update because of errors.');
$expected_log_message = TestCronUpdater::formatValidationException($exception);
}
else {
/** @var \Throwable $exception */
$exception = new $exception_class('Destroy the stage!');
TestChecker1::setException($exception, $event_class);
TestSubscriber1::setException($exception, $event_class);
$expected_log_message = $exception->getMessage();
}
// Ensure that nothing has been logged yet.
......@@ -364,7 +364,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase {
* @dataProvider providerErrors
*/
public function testErrors(array $validation_results, string $expected_log_message): void {
TestChecker1::setTestResult($validation_results, PreCreateEvent::class);
TestSubscriber1::setTestResult($validation_results, PreCreateEvent::class);
$this->container->get('cron')->run();
$this->assertUpdateStagedTimes(0);
$this->assertTrue($this->logger->hasRecord("<h2>Unable to complete the update because of errors.</h2>$expected_log_message", RfcLogLevel::ERROR));
......
......@@ -5,8 +5,8 @@ namespace Drupal\Tests\automatic_updates\Kernel\ReadinessValidation;
use Drupal\automatic_updates\CronUpdater;
use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\automatic_updates\Updater;
use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
use Drupal\automatic_updates_test2\ReadinessChecker\TestChecker2;
use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1;
use Drupal\automatic_updates_test2\EventSubscriber\TestSubscriber2;
use Drupal\system\SystemManager;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
......@@ -46,8 +46,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
array_pop($this->testResults['checker_1']),
array_pop($this->testResults['checker_2']),
];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
$expected_results_all = array_merge($expected_results[0], $expected_results[1]);
$this->assertCheckerResultsFromManager($expected_results_all, TRUE);
......@@ -68,8 +68,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], ReadinessCheckEvent::class);
TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
$expected_results_all = array_merge($expected_results[1], $expected_results[0]);
$this->assertCheckerResultsFromManager($expected_results_all, TRUE);
......@@ -92,7 +92,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
*/
public function testRunOnInstall(): void {
$expected_results = [array_pop($this->testResults['checker_1'])];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber1::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']);
......@@ -104,8 +104,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
array_pop($this->testResults['checker_1']),
array_pop($this->testResults['checker_2']),
];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber2::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);
......@@ -116,8 +116,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
array_pop($this->testResults['checker_1']),
array_pop($this->testResults['checker_2']),
];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
$expected_results_all = array_merge($expected_results[0], $expected_results[1]);
$this->container->get('module_installer')->install(['help']);
$this->assertCheckerResultsFromManager($expected_results_all);
......@@ -131,8 +131,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
array_pop($this->testResults['checker_1']),
array_pop($this->testResults['checker_2']),
];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestChecker2::setTestResult($expected_results[1], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber2::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']);
......@@ -144,8 +144,8 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
$expected_results = [
array_pop($this->testResults['checker_1']),
];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestChecker2::setTestResult(array_pop($this->testResults['checker_2']), ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber2::setTestResult(array_pop($this->testResults['checker_2']), ReadinessCheckEvent::class);
$this->container->get('module_installer')->uninstall(['automatic_updates_test2']);
$this->assertCheckerResultsFromManager($expected_results[0]);
......@@ -154,7 +154,7 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
$expected_results = [
array_pop($this->testResults['checker_1']),
];
TestChecker1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($expected_results[0], ReadinessCheckEvent::class);
$this->container->get('module_installer')->uninstall(['help']);
$this->assertCheckerResultsFromManager($expected_results[0]);
}
......@@ -165,12 +165,12 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
*/
public function testRunIfNeeded(): void {
$expected_results = array_pop($this->testResults['checker_1']);
TestChecker1::setTestResult($expected_results, ReadinessCheckEvent::class);
TestSubscriber1::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, ReadinessCheckEvent::class);
TestSubscriber1::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.
......@@ -186,7 +186,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, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($unexpected_results, ReadinessCheckEvent::class);
/** @var \Drupal\Core\DrupalKernel $kernel */
$kernel = $this->container->get('kernel');
$this->container = $kernel->rebuildContainer();
......@@ -227,13 +227,13 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
// The readiness checker should raise a warning, so that the update is not
// blocked or aborted.
$results = $this->testResults['checker_1']['1 warning'];
TestChecker1::setTestResult($results, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult($results, ReadinessCheckEvent::class);
// Ensure that the validation manager collects the warning.
/** @var \Drupal\automatic_updates\Validation\ReadinessValidationManager $manager */
$manager = $this->container->get('automatic_updates.readiness_validation_manager')
->run();
TestChecker1::setTestResult(NULL, ReadinessCheckEvent::class);
TestSubscriber1::setTestResult(NULL, ReadinessCheckEvent::class);
// Even though the checker no longer returns any results, the previous
// results should be stored.
$this->assertValidationResultsEqual($results, $manager->getResults());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment