From d01ff5cdbb0b9f7c6520d7eef5f4df054f0e813a Mon Sep 17 00:00:00 2001 From: Elber Rodrigues <58274-elber@users.noreply.drupalcode.org> Date: Fri, 25 Aug 2023 18:32:07 +0000 Subject: [PATCH] Issue #3375940: Rename CronUpdateStage to CronUpdateRunner --- automatic_updates.install | 4 +- automatic_updates.module | 14 ++-- automatic_updates.services.yml | 4 +- src/Commands/AutomaticUpdatesCommandBase.php | 4 +- src/Commands/RunCommand.php | 4 +- src/ConsoleUpdateStage.php | 6 +- ...onUpdateStage.php => CronUpdateRunner.php} | 7 +- src/Validation/AdminStatusCheckMessages.php | 10 +-- src/Validation/StatusChecker.php | 10 +-- src/Validator/CronFrequencyValidator.php | 8 +-- src/Validator/VersionPolicyValidator.php | 12 ++-- src/Validator/WindowsValidator.php | 8 +-- .../AutomaticUpdatesFunctionalTestBase.php | 4 +- .../ErrorMessageOnStageDestroyTest.php | 2 +- .../StatusCheckFailureEmailTest.php | 8 +-- tests/src/Functional/StatusCheckTest.php | 6 +- .../UpdateSettingsFormTest.php | 10 +-- .../Kernel/AutomaticUpdatesKernelTestBase.php | 14 ++-- tests/src/Kernel/ConsoleUpdateStageTest.php | 38 +++++------ ...StageTest.php => CronUpdateRunnerTest.php} | 16 ++--- .../CronFrequencyValidatorTest.php | 14 ++-- .../PhpExtensionsValidatorTest.php | 12 ++-- .../Kernel/StatusCheck/StatusCheckerTest.php | 4 +- .../VersionPolicyValidatorTest.php | 64 +++++++++---------- .../StatusCheck/WindowsValidatorTest.php | 16 ++--- 25 files changed, 148 insertions(+), 151 deletions(-) rename src/{CronUpdateStage.php => CronUpdateRunner.php} (95%) rename tests/src/Kernel/{CronUpdateStageTest.php => CronUpdateRunnerTest.php} (85%) diff --git a/automatic_updates.install b/automatic_updates.install index 6edec5369a..a8ffbb9df3 100644 --- a/automatic_updates.install +++ b/automatic_updates.install @@ -7,7 +7,7 @@ declare(strict_types = 1); -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\Validation\StatusCheckRequirements; use Drupal\system\SystemManager; @@ -30,7 +30,7 @@ function automatic_updates_requirements($phase) { // Check that site has cron updates enabled or not. // @todo Remove in https://www.drupal.org/project/automatic_updates/issues/3284443 - if (\Drupal::configFactory()->get('automatic_updates.settings')->get('unattended.level') !== CronUpdateStage::DISABLED) { + if (\Drupal::configFactory()->get('automatic_updates.settings')->get('unattended.level') !== CronUpdateRunner::DISABLED) { $requirements['automatic_updates_cron'] = [ 'title' => t('Cron installs updates automatically'), 'severity' => SystemManager::REQUIREMENT_WARNING, diff --git a/automatic_updates.module b/automatic_updates.module index f1b8324b7d..f6d918fa15 100644 --- a/automatic_updates.module +++ b/automatic_updates.module @@ -8,7 +8,7 @@ declare(strict_types = 1); use Drupal\automatic_updates\BatchProcessor; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\automatic_updates\Validation\AdminStatusCheckMessages; @@ -159,12 +159,12 @@ function automatic_updates_modules_installed($modules) { /** @var \Drupal\automatic_updates\Validation\StatusChecker $status_checker */ $status_checker = \Drupal::service('automatic_updates.status_checker'); $status_checker->run(); - /** @var \Drupal\automatic_updates\CronUpdateStage $stage */ + /** @var \Drupal\automatic_updates\CronUpdateRunner $stage */ $stage = \Drupal::service('automatic_updates.cron_update_stage'); // If cron updates are disabled status check messages will not be displayed on // admin pages. Therefore, after installing the module the user will not be // alerted to any problems until they access the status report page. - if ($stage->getMode() === CronUpdateStage::DISABLED) { + if ($stage->getMode() === CronUpdateRunner::DISABLED) { /** @var \Drupal\automatic_updates\Validation\AdminStatusCheckMessages $status_check_messages */ $status_check_messages = \Drupal::classResolver(AdminStatusCheckMessages::class); $status_check_messages->displayResultSummary(); @@ -205,9 +205,9 @@ function automatic_updates_form_update_settings_alter(array &$form): void { '#type' => 'radios', '#title' => t('Unattended background updates'), '#options' => [ - CronUpdateStage::DISABLED => t('Disabled'), - CronUpdateStage::SECURITY => t('Security updates only'), - CronUpdateStage::ALL => t('All patch releases'), + CronUpdateRunner::DISABLED => t('Disabled'), + CronUpdateRunner::SECURITY => t('Security updates only'), + CronUpdateRunner::ALL => t('All patch releases'), ], '#default_value' => $config->get('unattended.level'), '#description' => t('When background updates are applied, your site will be briefly put into maintenance mode.'), @@ -223,7 +223,7 @@ function automatic_updates_form_update_settings_alter(array &$form): void { '#states' => [ 'invisible' => [ 'input[name="unattended_level"]' => [ - 'value' => CronUpdateStage::DISABLED, + 'value' => CronUpdateRunner::DISABLED, ], ], ], diff --git a/automatic_updates.services.yml b/automatic_updates.services.yml index 4cf74b0526..9abcb5d526 100644 --- a/automatic_updates.services.yml +++ b/automatic_updates.services.yml @@ -24,13 +24,13 @@ services: - ['setLogger', ['@logger.channel.automatic_updates']] Drupal\automatic_updates\UpdateStage: '@automatic_updates.update_stage' automatic_updates.cron_update_stage: - class: Drupal\automatic_updates\CronUpdateStage + class: Drupal\automatic_updates\CronUpdateRunner calls: - ['setLogger', ['@logger.channel.automatic_updates']] arguments: $inner: '@automatic_updates.cron_update_stage.inner' decorates: 'cron' - Drupal\automatic_updates\CronUpdateStage: '@automatic_updates.cron_update_stage' + Drupal\automatic_updates\CronUpdateRunner: '@automatic_updates.cron_update_stage' automatic_updates.requested_update_validator: class: Drupal\automatic_updates\Validator\RequestedUpdateValidator tags: diff --git a/src/Commands/AutomaticUpdatesCommandBase.php b/src/Commands/AutomaticUpdatesCommandBase.php index f387dc77ff..a0396d453a 100644 --- a/src/Commands/AutomaticUpdatesCommandBase.php +++ b/src/Commands/AutomaticUpdatesCommandBase.php @@ -3,7 +3,7 @@ namespace Drupal\automatic_updates\Commands; use Drupal\automatic_updates\ConsoleUpdateStage; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\StatusCheckMailer; use Drupal\automatic_updates\Validation\StatusChecker; use Drupal\Component\Datetime\TimeInterface; @@ -130,7 +130,7 @@ abstract class AutomaticUpdatesCommandBase extends Command { // explicitly configured to do unattended updates on the command line. if ($needs_run && (($settings['method'] === 'web' && $this->stage->isFromWeb) || $settings['method'] === 'console')) { // Only send failure notifications if unattended updates are enabled. - if ($settings['level'] !== CronUpdateStage::DISABLED) { + if ($settings['level'] !== CronUpdateRunner::DISABLED) { $this->container->get(StatusCheckMailer::class) ->sendFailureNotifications($last_results, $status_checker->run()->getResults()); } diff --git a/src/Commands/RunCommand.php b/src/Commands/RunCommand.php index 7dea7721fb..51f37181a7 100644 --- a/src/Commands/RunCommand.php +++ b/src/Commands/RunCommand.php @@ -2,7 +2,7 @@ namespace Drupal\automatic_updates\Commands; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; use Symfony\Component\Console\Input\InputInterface; @@ -39,7 +39,7 @@ final class RunCommand extends AutomaticUpdatesCommandBase { protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); - $runner = $this->container->get(CronUpdateStage::class); + $runner = $this->container->get(CronUpdateRunner::class); if ($runner->getMode() === $runner::DISABLED) { $message = $this->t('Automatic updates are disabled. Visit the update settings form at @url to enable them.', [ '@url' => Url::fromRoute('update.settings')->toString(), diff --git a/src/ConsoleUpdateStage.php b/src/ConsoleUpdateStage.php index 3927fe18cb..071c115cc1 100644 --- a/src/ConsoleUpdateStage.php +++ b/src/ConsoleUpdateStage.php @@ -64,7 +64,7 @@ class ConsoleUpdateStage extends UpdateStage { * * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock service. - * @param \Drupal\automatic_updates\CronUpdateStage $cronUpdateRunner + * @param \Drupal\automatic_updates\CronUpdateRunner $cronUpdateRunner * The cron update runner service. * @param \Drupal\Core\Mail\MailManagerInterface $mailManager * The mail manager service. @@ -99,7 +99,7 @@ class ConsoleUpdateStage extends UpdateStage { */ public function __construct( private readonly LockBackendInterface $lock, - private readonly CronUpdateStage $cronUpdateRunner, + private readonly CronUpdateRunner $cronUpdateRunner, private readonly MailManagerInterface $mailManager, private readonly StatusCheckMailer $statusCheckMailer, private readonly ReleaseChooser $releaseChooser, @@ -152,7 +152,7 @@ class ConsoleUpdateStage extends UpdateStage { * Returns TRUE if any update was attempted, otherwise FALSE. */ public function performUpdate(): bool { - if ($this->cronUpdateRunner->getMode() === CronUpdateStage::DISABLED) { + if ($this->cronUpdateRunner->getMode() === CronUpdateRunner::DISABLED) { return FALSE; } diff --git a/src/CronUpdateStage.php b/src/CronUpdateRunner.php similarity index 95% rename from src/CronUpdateStage.php rename to src/CronUpdateRunner.php index ad7deb6ff5..ce64990141 100644 --- a/src/CronUpdateStage.php +++ b/src/CronUpdateRunner.php @@ -21,16 +21,13 @@ use Psr\Log\NullLogger; * run regardless of whether there is an update available and whether an update * is successful. * - * @todo Rename this class to CronUpdateRunner because it is no longer a stage - * in https://drupal.org/i/3375940. - * * @internal * This class implements logic specific to Automatic Updates' cron hook * implementation and may be changed or removed at any time without warning. * It should not be called directly, and external code should not interact * with it. */ -class CronUpdateStage implements CronInterface, LoggerAwareInterface { +class CronUpdateRunner implements CronInterface, LoggerAwareInterface { use LoggerAwareTrait; @@ -63,7 +60,7 @@ class CronUpdateStage implements CronInterface, LoggerAwareInterface { public const ALL = 'patch'; /** - * Constructs a CronUpdateStage object. + * Constructs a CronUpdateRunner object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory service. diff --git a/src/Validation/AdminStatusCheckMessages.php b/src/Validation/AdminStatusCheckMessages.php index 57761dbfcc..61955892e4 100644 --- a/src/Validation/AdminStatusCheckMessages.php +++ b/src/Validation/AdminStatusCheckMessages.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\automatic_updates\Validation; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Messenger\MessengerInterface; @@ -46,8 +46,8 @@ final class AdminStatusCheckMessages implements ContainerInjectionInterface { * The current user. * @param \Drupal\Core\Routing\CurrentRouteMatch $currentRouteMatch * The current route match. - * @param \Drupal\automatic_updates\CronUpdateStage $stage - * The cron update stage service. + * @param \Drupal\automatic_updates\CronUpdateRunner $runner + * The cron update runner service. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory @@ -58,7 +58,7 @@ final class AdminStatusCheckMessages implements ContainerInjectionInterface { private readonly AdminContext $adminContext, private readonly AccountProxyInterface $currentUser, private readonly CurrentRouteMatch $currentRouteMatch, - private readonly CronUpdateStage $stage, + private readonly CronUpdateRunner $runner, private readonly RendererInterface $renderer, private readonly ConfigFactoryInterface $configFactory ) {} @@ -120,7 +120,7 @@ final class AdminStatusCheckMessages implements ContainerInjectionInterface { private function displayResultsOnCurrentPage(): bool { // If updates will not run during cron then we don't need to show the // status checks on admin pages. - if ($this->stage->getMode() === CronUpdateStage::DISABLED) { + if ($this->runner->getMode() === CronUpdateRunner::DISABLED) { return FALSE; } diff --git a/src/Validation/StatusChecker.php b/src/Validation/StatusChecker.php index 8a856edfe9..a94eb0fd40 100644 --- a/src/Validation/StatusChecker.php +++ b/src/Validation/StatusChecker.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\automatic_updates\Validation; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\automatic_updates\StatusCheckMailer; use Drupal\Core\Config\ConfigCrudEvent; @@ -45,8 +45,8 @@ final class StatusChecker implements EventSubscriberInterface { * The update stage service. * @param \Drupal\automatic_updates\ConsoleUpdateStage $consoleUpdateStage * The console update stage service. - * @param \Drupal\automatic_updates\CronUpdateStage $cronUpdateStage - * The cron update stage service. + * @param \Drupal\automatic_updates\CronUpdateRunner $cronUpdateRunner + * The cron update runner service. * @param int $resultsTimeToLive * The number of hours to store results. */ @@ -56,7 +56,7 @@ final class StatusChecker implements EventSubscriberInterface { private readonly EventDispatcherInterface $eventDispatcher, private readonly UpdateStage $updateStage, private readonly ConsoleUpdateStage $consoleUpdateStage, - private readonly CronUpdateStage $cronUpdateStage, + private readonly CronUpdateRunner $cronUpdateRunner, private readonly int $resultsTimeToLive, ) { $this->keyValueExpirable = $key_value_expirable_factory->get('automatic_updates'); @@ -71,7 +71,7 @@ final class StatusChecker implements EventSubscriberInterface { // If updates will run during cron, use the console update stage service // provided by this module. This will allow validators to run specific // validation for conditions that only affect cron updates. - if ($this->cronUpdateStage->getMode() === CronUpdateStage::DISABLED) { + if ($this->cronUpdateRunner->getMode() === CronUpdateRunner::DISABLED) { $stage = $this->updateStage; } else { diff --git a/src/Validator/CronFrequencyValidator.php b/src/Validator/CronFrequencyValidator.php index 7685148a81..7d10746f89 100644 --- a/src/Validator/CronFrequencyValidator.php +++ b/src/Validator/CronFrequencyValidator.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\automatic_updates\Validator; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Config\ConfigFactoryInterface; @@ -56,7 +56,7 @@ final class CronFrequencyValidator implements EventSubscriberInterface { /** * CronFrequencyValidator constructor. * - * @param \Drupal\automatic_updates\CronUpdateStage $cronUpdateRunner + * @param \Drupal\automatic_updates\CronUpdateRunner $cronUpdateRunner * The cron update runner service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory service. @@ -68,7 +68,7 @@ final class CronFrequencyValidator implements EventSubscriberInterface { * The lock service. */ public function __construct( - private readonly CronUpdateStage $cronUpdateRunner, + private readonly CronUpdateRunner $cronUpdateRunner, private readonly ConfigFactoryInterface $configFactory, private readonly StateInterface $state, private readonly TimeInterface $time, @@ -90,7 +90,7 @@ final class CronFrequencyValidator implements EventSubscriberInterface { // the console command, there's nothing we need to validate. $method = $this->configFactory->get('automatic_updates.settings') ->get('unattended.method'); - if ($this->cronUpdateRunner->getMode() === CronUpdateStage::DISABLED || $method !== 'web') { + if ($this->cronUpdateRunner->getMode() === CronUpdateRunner::DISABLED || $method !== 'web') { return; } // If cron is running right now, cron is clearly being run recently enough! diff --git a/src/Validator/VersionPolicyValidator.php b/src/Validator/VersionPolicyValidator.php index a6f26501bc..0ae4aaaf00 100644 --- a/src/Validator/VersionPolicyValidator.php +++ b/src/Validator/VersionPolicyValidator.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\automatic_updates\Validator; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\Component\Utility\NestedArray; use Drupal\package_manager\ComposerInspector; @@ -42,7 +42,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { /** * Constructs a VersionPolicyValidator object. * - * @param \Drupal\automatic_updates\CronUpdateStage $cronUpdateRunner + * @param \Drupal\automatic_updates\CronUpdateRunner $cronUpdateRunner * The cron update runner service. * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $classResolver * The class resolver service. @@ -52,7 +52,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { * The Composer inspector service. */ public function __construct( - private readonly CronUpdateStage $cronUpdateRunner, + private readonly CronUpdateRunner $cronUpdateRunner, private readonly ClassResolverInterface $classResolver, private readonly PathLocator $pathLocator, private readonly ComposerInspector $composerInspector, @@ -92,7 +92,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { if ($stage instanceof ConsoleUpdateStage) { $mode = $this->cronUpdateRunner->getMode(); - if ($mode !== CronUpdateStage::DISABLED) { + if ($mode !== CronUpdateRunner::DISABLED) { // If cron updates are enabled, the installed version must be stable; // no alphas, betas, or RCs. $rules[] = StableReleaseInstalled::class; @@ -108,7 +108,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { // If only security updates are allowed during cron, the target // version must be a security release. - if ($mode === CronUpdateStage::SECURITY) { + if ($mode === CronUpdateRunner::SECURITY) { $rules[] = TargetSecurityRelease::class; } } @@ -260,7 +260,7 @@ final class VersionPolicyValidator implements EventSubscriberInterface { * @return \Drupal\update\ProjectRelease[] * The available releases of Drupal core, keyed by version number and in * descending order (i.e., newest first). Will be in ascending order (i.e., - * oldest first) if $stage is the cron update stage. + * oldest first) if $stage is the cron update runner. * * @see \Drupal\package_manager\ProjectInfo::getInstallableReleases() */ diff --git a/src/Validator/WindowsValidator.php b/src/Validator/WindowsValidator.php index 6de26a3dbf..3e2a79f206 100644 --- a/src/Validator/WindowsValidator.php +++ b/src/Validator/WindowsValidator.php @@ -4,8 +4,8 @@ declare(strict_types = 1); namespace Drupal\automatic_updates\Validator; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; -use Drupal\automatic_updates\CronUpdateStage; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Url; @@ -31,13 +31,13 @@ final class WindowsValidator implements EventSubscriberInterface { /** * Constructs a WindowsValidator object. * - * @param \Drupal\automatic_updates\CronUpdateStage $cronRunner + * @param \Drupal\automatic_updates\CronUpdateRunner $cronRunner * The cron update runner service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory service. */ public function __construct( - private readonly CronUpdateStage $cronRunner, + private readonly CronUpdateRunner $cronRunner, private readonly ConfigFactoryInterface $configFactory, ) {} @@ -67,7 +67,7 @@ final class WindowsValidator implements EventSubscriberInterface { ->get('unattended.method'); $stage = $event->stage; - if ($stage instanceof ConsoleUpdateStage && $this->cronRunner->getMode() !== CronUpdateStage::DISABLED && $method === 'web') { + if ($stage instanceof ConsoleUpdateStage && $this->cronRunner->getMode() !== CronUpdateRunner::DISABLED && $method === 'web') { $message = $this->t('Unattended updates are not supported on Windows.'); $form_url = Url::fromRoute('update.report_update'); diff --git a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php index 0eee7a43a4..c900eee318 100644 --- a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php +++ b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php @@ -4,8 +4,8 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Functional; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\CommandExecutor; -use Drupal\automatic_updates\CronUpdateStage; use Drupal\fixture_manipulator\StageFixtureManipulator; use Drupal\package_manager\PathLocator; use Drupal\Tests\BrowserTestBase; @@ -41,7 +41,7 @@ abstract class AutomaticUpdatesFunctionalTestBase extends BrowserTestBase { $this->useFixtureDirectoryAsActive(__DIR__ . '/../../../package_manager/tests/fixtures/fake_site'); // @todo Remove in https://www.drupal.org/project/automatic_updates/issues/3284443 $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::SECURITY) + ->set('unattended.level', CronUpdateRunner::SECURITY) ->save(); } diff --git a/tests/src/Functional/ErrorMessageOnStageDestroyTest.php b/tests/src/Functional/ErrorMessageOnStageDestroyTest.php index f3426ab465..90b995bfab 100644 --- a/tests/src/Functional/ErrorMessageOnStageDestroyTest.php +++ b/tests/src/Functional/ErrorMessageOnStageDestroyTest.php @@ -57,7 +57,7 @@ class ErrorMessageOnStageDestroyTest extends AutomaticUpdatesFunctionalTestBase $stage = $this->container->get(UpdateStage::class); $random_message = $this->randomString(); // @see \Drupal\Tests\package_manager\Kernel\StageTest::testStoreDestroyInfo() - // @see \Drupal\automatic_updates\CronUpdateStage::performUpdate() + // @see \Drupal\automatic_updates\CronUpdateRunner::performUpdate() $stage->destroy(TRUE, t($random_message)); $this->checkForMetaRefresh(); $page->pressButton('Continue'); diff --git a/tests/src/Functional/StatusCheckFailureEmailTest.php b/tests/src/Functional/StatusCheckFailureEmailTest.php index 0e63365973..f1c6d0df2a 100644 --- a/tests/src/Functional/StatusCheckFailureEmailTest.php +++ b/tests/src/Functional/StatusCheckFailureEmailTest.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Functional; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\StatusCheckMailer; use Drupal\automatic_updates_test\Datetime\TestTime; use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1; @@ -53,7 +53,7 @@ class StatusCheckFailureEmailTest extends AutomaticUpdatesFunctionalTestBase { // @todo Remove in https://www.drupal.org/project/automatic_updates/issues/3284443 $this->config('automatic_updates.settings') ->set('unattended', [ - 'level' => CronUpdateStage::SECURITY, + 'level' => CronUpdateRunner::SECURITY, 'method' => 'console', ]) ->save(); @@ -199,7 +199,7 @@ END; // If we disable unattended updates entirely and flag a new error, they // should not be e-mailed. - $config->set('unattended.level', CronUpdateStage::DISABLED)->save(); + $config->set('unattended.level', CronUpdateRunner::DISABLED)->save(); $error = $this->createValidationResult(SystemManager::REQUIREMENT_ERROR); TestSubscriber1::setTestResult([$error], StatusCheckEvent::class); $this->runConsoleUpdateCommand(); @@ -207,7 +207,7 @@ END; // If we re-enable unattended updates, they should be emailed again, even if // the results haven't changed. - $config->set('unattended.level', CronUpdateStage::SECURITY)->save(); + $config->set('unattended.level', CronUpdateRunner::SECURITY)->save(); $this->runConsoleUpdateCommand(); $sent_messages_count += $recipient_count; $this->assertSentMessagesCount($sent_messages_count); diff --git a/tests/src/Functional/StatusCheckTest.php b/tests/src/Functional/StatusCheckTest.php index 9aec212edf..c99abad6da 100644 --- a/tests/src/Functional/StatusCheckTest.php +++ b/tests/src/Functional/StatusCheckTest.php @@ -5,7 +5,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Functional; use Behat\Mink\Element\NodeElement; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\StatusCheckMailer; use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1; use Drupal\automatic_updates_test_status_checker\EventSubscriber\TestSubscriber2; @@ -363,7 +363,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase { // Confirm status check messages are not displayed when cron updates are // disabled. $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::DISABLED) + ->set('unattended.level', CronUpdateRunner::DISABLED) ->save(); $this->drupalGet('admin/structure'); $this->checkForMetaRefresh(); @@ -387,7 +387,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase { $this->container->get('module_installer')->install(['automatic_updates', 'automatic_updates_test']); // @todo Remove in https://www.drupal.org/project/automatic_updates/issues/3284443 $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::SECURITY) + ->set('unattended.level', CronUpdateRunner::SECURITY) ->save(); $this->drupalGet('admin/reports/status'); $this->assertNoErrors(TRUE); diff --git a/tests/src/FunctionalJavascript/UpdateSettingsFormTest.php b/tests/src/FunctionalJavascript/UpdateSettingsFormTest.php index a6b45191d9..32aef05524 100644 --- a/tests/src/FunctionalJavascript/UpdateSettingsFormTest.php +++ b/tests/src/FunctionalJavascript/UpdateSettingsFormTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\automatic_updates\FunctionalJavascript; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** @@ -31,14 +31,14 @@ class UpdateSettingsFormTest extends WebDriverTestBase { // The default values should be reflected. $assert_session = $this->assertSession(); $assert_session->fieldValueEquals('unattended_method', 'web'); - $assert_session->fieldValueEquals('unattended_level', CronUpdateStage::DISABLED); + $assert_session->fieldValueEquals('unattended_level', CronUpdateRunner::DISABLED); // Since unattended updates are disabled, the method radio buttons should be // hidden. $this->assertFalse($assert_session->fieldExists('unattended_method')->isVisible()); // Enabling unattended updates should reveal the method radio buttons. $page = $this->getSession()->getPage(); - $page->selectFieldOption('unattended_level', CronUpdateStage::SECURITY); + $page->selectFieldOption('unattended_level', CronUpdateRunner::SECURITY); $this->assertNotEmpty($assert_session->waitForElementVisible('named', ['field', 'unattended_method'])); $assert_session->elementAttributeContains('named', ['link', 'ensure cron is set up correctly'], 'href', 'http://drupal.org/docs/user_guide/en/security-cron.html'); // Change the method, to ensure it is properly saved in config. @@ -47,10 +47,10 @@ class UpdateSettingsFormTest extends WebDriverTestBase { // Ensure the changes are reflected in config. $page->pressButton('Save configuration'); $config = $this->config('automatic_updates.settings'); - $this->assertSame(CronUpdateStage::SECURITY, $config->get('unattended.level')); + $this->assertSame(CronUpdateRunner::SECURITY, $config->get('unattended.level')); $this->assertSame('console', $config->get('unattended.method')); // Our saved changes should be reflected in the form too. - $assert_session->fieldValueEquals('unattended_level', CronUpdateStage::SECURITY); + $assert_session->fieldValueEquals('unattended_level', CronUpdateRunner::SECURITY); $assert_session->fieldValueEquals('unattended_method', 'console'); } diff --git a/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php b/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php index 29a4644b81..c82295e553 100644 --- a/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php +++ b/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait; @@ -54,7 +54,7 @@ abstract class AutomaticUpdatesKernelTestBase extends PackageManagerKernelTestBa $this->config('automatic_updates.settings') ->set('unattended', [ 'method' => 'web', - 'level' => CronUpdateStage::SECURITY, + 'level' => CronUpdateRunner::SECURITY, ]) ->save(); @@ -72,7 +72,7 @@ abstract class AutomaticUpdatesKernelTestBase extends PackageManagerKernelTestBa // our cron handler's PHP_SAPI constant to a valid value that isn't `cli`. // The choice of `cgi-fcgi` is arbitrary; see // https://www.php.net/php_sapi_name for some valid values of PHP_SAPI. - $property = new \ReflectionProperty(CronUpdateStage::class, 'serverApi'); + $property = new \ReflectionProperty(CronUpdateRunner::class, 'serverApi'); $property->setValue(NULL, 'cgi-fcgi'); } @@ -82,9 +82,9 @@ abstract class AutomaticUpdatesKernelTestBase extends PackageManagerKernelTestBa public function register(ContainerBuilder $container) { parent::register($container); - // Use the test-only implementations of the regular and cron update stages. + // Use the test-only implementations of the regular and cron update runner. $overrides = [ - 'automatic_updates.cron_update_stage' => TestCronUpdateStage::class, + 'automatic_updates.cron_update_stage' => TestCronUpdateRunner::class, ConsoleUpdateStage::class => TestConsoleUpdateStage::class, ]; foreach ($overrides as $service_id => $class) { @@ -104,9 +104,9 @@ abstract class AutomaticUpdatesKernelTestBase extends PackageManagerKernelTestBa } /** - * A test-only version of the cron update stage to override and expose internals. + * A test-only version of the cron update runner to override and expose internals. */ -class TestCronUpdateStage extends CronUpdateStage { +class TestCronUpdateRunner extends CronUpdateRunner { /** * {@inheritdoc} diff --git a/tests/src/Kernel/ConsoleUpdateStageTest.php b/tests/src/Kernel/ConsoleUpdateStageTest.php index b82765f102..3ea019918c 100644 --- a/tests/src/Kernel/ConsoleUpdateStageTest.php +++ b/tests/src/Kernel/ConsoleUpdateStageTest.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1; use Drupal\Core\DependencyInjection\ContainerBuilder; @@ -139,32 +139,32 @@ END; $fixture_dir = __DIR__ . '/../../../package_manager/tests/fixtures/release-history'; return [ 'disabled, normal release' => [ - CronUpdateStage::DISABLED, + CronUpdateRunner::DISABLED, ['drupal' => "$fixture_dir/drupal.9.8.2.xml"], FALSE, ], 'disabled, security release' => [ - CronUpdateStage::DISABLED, + CronUpdateRunner::DISABLED, ['drupal' => "$fixture_dir/drupal.9.8.1-security.xml"], FALSE, ], 'security only, security release' => [ - CronUpdateStage::SECURITY, + CronUpdateRunner::SECURITY, ['drupal' => "$fixture_dir/drupal.9.8.1-security.xml"], TRUE, ], 'security only, normal release' => [ - CronUpdateStage::SECURITY, + CronUpdateRunner::SECURITY, ['drupal' => "$fixture_dir/drupal.9.8.2.xml"], FALSE, ], 'enabled, normal release' => [ - CronUpdateStage::ALL, + CronUpdateRunner::ALL, ['drupal' => "$fixture_dir/drupal.9.8.2.xml"], TRUE, ], 'enabled, security release' => [ - CronUpdateStage::ALL, + CronUpdateRunner::ALL, ['drupal' => "$fixture_dir/drupal.9.8.1-security.xml"], TRUE, ], @@ -297,7 +297,7 @@ END; $this->installConfig('automatic_updates'); // @todo Remove in https://www.drupal.org/project/automatic_updates/issues/3284443 $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::SECURITY) + ->set('unattended.level', CronUpdateRunner::SECURITY) ->save(); // Ensure that there is a security release to which we should update. $this->setReleaseMetadata([ @@ -305,7 +305,7 @@ END; ]); // If the pre- or post-destroy events throw an exception, it will not be - // caught by the cron update stage, but it *will* be caught by the main cron + // caught by the cron update runner, but it *will* be caught by the main cron // service, which will log it as a cron error that we'll want to check for. $cron_logger = new TestLogger(); $this->container->get('logger.factory') @@ -358,9 +358,9 @@ END; $logged_by_cron = $cron_logger->hasRecordThatPasses($predicate, (string) RfcLogLevel::ERROR); // If a pre-destroy event flags a validation error, it's handled like any - // other event (logged by the cron update stage, but not the main cron + // other event (logged by the cron update runner, but not the main cron // service). But if a pre- or post-destroy event throws an exception, the - // cron update stage won't try to catch it. Instead, it will be caught and + // cron update runner won't try to catch it. Instead, it will be caught and // logged by the main cron service. if ($event_class === PreDestroyEvent::class || $event_class === PostDestroyEvent::class) { // If the pre-destroy event throws an exception or flags a validation @@ -411,7 +411,7 @@ END; */ public function testStageNotDestroyedIfApplying(): void { $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::ALL) + ->set('unattended.level', CronUpdateRunner::ALL) ->save(); $this->setReleaseMetadata([ 'drupal' => __DIR__ . "/../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml", @@ -451,7 +451,7 @@ END; */ public function testStageNotDestroyedIfSecure(): void { $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::ALL) + ->set('unattended.level', CronUpdateRunner::ALL) ->save(); $this->setReleaseMetadata([ 'drupal' => __DIR__ . "/../../../package_manager/tests/fixtures/release-history/drupal.9.8.2.xml", @@ -462,7 +462,7 @@ END; $stage->require(['drupal/random']); $this->assertUpdateStagedTimes(1); - // Trigger CronUpdateStage, the above should cause it to detect a stage that + // Trigger CronUpdateRunner, the above should cause it to detect a stage that // is applying. $this->runConsoleUpdateStage(); @@ -471,7 +471,7 @@ END; } /** - * Tests that CronUpdateStage::begin() unconditionally throws an exception. + * Tests that CronUpdateRunner::begin() unconditionally throws an exception. */ public function testBeginThrowsException(): void { $this->expectExceptionMessage(ConsoleUpdateStage::class . '::begin() cannot be called directly.'); @@ -537,7 +537,7 @@ END; 'drupal' => __DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.2.xml', ]); $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::ALL) + ->set('unattended.level', CronUpdateRunner::ALL) ->save(); $error = ValidationResult::createError([ @@ -629,7 +629,7 @@ END; } /** - * Tests that setLogger is called on the cron update stage service. + * Tests that setLogger is called on the cron update runner service. */ public function testLoggerIsSetByContainer(): void { $stage_method_calls = $this->container->getDefinition('automatic_updates.cron_update_stage')->getMethodCalls(); @@ -649,9 +649,9 @@ END; $this->assertNull($state->get('system.maintenance_mode')); $this->runConsoleUpdateStage(); $state->resetCache(); - // @see \Drupal\Tests\automatic_updates\Kernel\TestCronUpdateStage::apply() + // @see \Drupal\Tests\automatic_updates\Kernel\TestCronUpdateRunner::apply() $this->assertTrue($this->logger->hasRecord('Unattended update was applied in maintenance mode.', RfcLogLevel::INFO)); - // @see \Drupal\Tests\automatic_updates\Kernel\TestCronUpdateStage::postApply() + // @see \Drupal\Tests\automatic_updates\Kernel\TestCronUpdateRunner::postApply() $this->assertTrue($this->logger->hasRecord('postApply() was called in maintenance mode.', RfcLogLevel::INFO)); // During post-apply, maintenance mode should have been explicitly turned // off (i.e., set to FALSE). diff --git a/tests/src/Kernel/CronUpdateStageTest.php b/tests/src/Kernel/CronUpdateRunnerTest.php similarity index 85% rename from tests/src/Kernel/CronUpdateStageTest.php rename to tests/src/Kernel/CronUpdateRunnerTest.php index 1b8c625a5a..1ec1df459a 100644 --- a/tests/src/Kernel/CronUpdateStageTest.php +++ b/tests/src/Kernel/CronUpdateRunnerTest.php @@ -4,14 +4,14 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; /** - * @coversDefaultClass \Drupal\automatic_updates\CronUpdateStage + * @coversDefaultClass \Drupal\automatic_updates\CronUpdateRunner * @group automatic_updates * @internal */ -class CronUpdateStageTest extends AutomaticUpdatesKernelTestBase { +class CronUpdateRunnerTest extends AutomaticUpdatesKernelTestBase { /** * {@inheritdoc} @@ -36,14 +36,14 @@ class CronUpdateStageTest extends AutomaticUpdatesKernelTestBase { // Undo override of the 'serverApi' property from the parent test class. // @see \Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase::setUp - $property = new \ReflectionProperty(CronUpdateStage::class, 'serverApi'); + $property = new \ReflectionProperty(CronUpdateRunner::class, 'serverApi'); $property->setValue(NULL, 'cli'); - $this->assertTrue(CronUpdateStage::isCommandLine()); + $this->assertTrue(CronUpdateRunner::isCommandLine()); // Since we're at the command line, the terminal command should not be // invoked. Since we are in a kernel test, there would be an exception // if that happened. - // @see \Drupal\Tests\automatic_updates\Kernel\TestCronUpdateStage::runTerminalUpdateCommand + // @see \Drupal\Tests\automatic_updates\Kernel\TestCronUpdateRunner::runTerminalUpdateCommand $this->container->get('cron')->run(); // Even though the terminal command was not invoked, hook_cron // implementations should have been run. @@ -52,7 +52,7 @@ class CronUpdateStageTest extends AutomaticUpdatesKernelTestBase { // If we are on the web but the method is set to 'console' the terminal // command should not be invoked. $property->setValue(NULL, 'cgi-fcgi'); - $this->assertFalse(CronUpdateStage::isCommandLine()); + $this->assertFalse(CronUpdateRunner::isCommandLine()); $this->config('automatic_updates.settings') ->set('unattended.method', 'console') ->save(); @@ -69,7 +69,7 @@ class CronUpdateStageTest extends AutomaticUpdatesKernelTestBase { $this->fail('Expected an exception when running updates via cron.'); } catch (\BadMethodCallException $e) { - $this->assertSame(TestCronUpdateStage::class, $e->getMessage()); + $this->assertSame(TestCronUpdateRunner::class, $e->getMessage()); } // Even though the terminal command threw exception hook_cron // implementations should have been invoked before this. diff --git a/tests/src/Kernel/StatusCheck/CronFrequencyValidatorTest.php b/tests/src/Kernel/StatusCheck/CronFrequencyValidatorTest.php index 871eb07b16..d2ff7499c9 100644 --- a/tests/src/Kernel/StatusCheck/CronFrequencyValidatorTest.php +++ b/tests/src/Kernel/StatusCheck/CronFrequencyValidatorTest.php @@ -4,10 +4,10 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel\StatusCheck; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\package_manager\ValidationResult; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; -use Drupal\Tests\automatic_updates\Kernel\TestCronUpdateStage; +use Drupal\Tests\automatic_updates\Kernel\TestCronUpdateRunner; /** * @covers \Drupal\automatic_updates\Validator\CronFrequencyValidator @@ -46,7 +46,7 @@ class CronFrequencyValidatorTest extends AutomaticUpdatesKernelTestBase { // If the method is 'web' but cron updates are disabled no validation is // needed. $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::DISABLED) + ->set('unattended.level', CronUpdateRunner::DISABLED) ->set('unattended.method', 'web') ->save(); $this->assertCheckerResultsFromManager([], TRUE); @@ -54,14 +54,14 @@ class CronFrequencyValidatorTest extends AutomaticUpdatesKernelTestBase { // If cron updates are enabled but the method is 'console' no validation is // needed. $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::ALL) + ->set('unattended.level', CronUpdateRunner::ALL) ->set('unattended.method', 'console') ->save(); $this->assertCheckerResultsFromManager([], TRUE); // If cron updates are enabled and the method is 'web' validation is needed. $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::ALL) + ->set('unattended.level', CronUpdateRunner::ALL) ->set('unattended.method', 'web') ->save(); $error = ValidationResult::createError([ @@ -118,12 +118,12 @@ class CronFrequencyValidatorTest extends AutomaticUpdatesKernelTestBase { catch (\BadMethodCallException $e) { // The terminal command cannot be run in a kernel test. // @see \Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase::runUpdateViaConsole - $this->assertSame(TestCronUpdateStage::class, $e->getMessage()); + $this->assertSame(TestCronUpdateRunner::class, $e->getMessage()); // After cron runs, the validator should detect that cron ran recently. // Even though the terminal command did not succeed, the decorated cron // service from the System module should have been called before the // attempt to run the terminal command. - // @see \Drupal\automatic_updates\CronUpdateStage::run + // @see \Drupal\automatic_updates\CronUpdateRunner::run $this->assertCheckerResultsFromManager([], TRUE); } } diff --git a/tests/src/Kernel/StatusCheck/PhpExtensionsValidatorTest.php b/tests/src/Kernel/StatusCheck/PhpExtensionsValidatorTest.php index 0c1c456187..7552a8d91f 100644 --- a/tests/src/Kernel/StatusCheck/PhpExtensionsValidatorTest.php +++ b/tests/src/Kernel/StatusCheck/PhpExtensionsValidatorTest.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel\StatusCheck; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\Core\Logger\RfcLogLevel; use Drupal\package_manager\ValidationResult; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; @@ -44,12 +44,12 @@ class PhpExtensionsValidatorTest extends AutomaticUpdatesKernelTestBase { // If unattended updates are disabled, we should only see a warning from // Package Manager. - $config->set('unattended.level', CronUpdateStage::DISABLED)->save(); + $config->set('unattended.level', CronUpdateRunner::DISABLED)->save(); $this->assertCheckerResultsFromManager([$warning_result], TRUE); // The parent class' setUp() method simulates an available security update, - // so ensure that the cron update stage will try to update to it. - $config->set('unattended.level', CronUpdateStage::SECURITY)->save(); + // so ensure that the cron update runner will try to update to it. + $config->set('unattended.level', CronUpdateRunner::SECURITY)->save(); // If unattended updates are enabled, we should see an error from Automatic // Updates. @@ -75,9 +75,9 @@ class PhpExtensionsValidatorTest extends AutomaticUpdatesKernelTestBase { $this->addEventTestListener($this->simulateXdebugEnabled(...)); // The parent class' setUp() method simulates an available security - // update, so ensure that the cron update stage will try to update to it. + // update, so ensure that the cron update runner will try to update to it. $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::SECURITY) + ->set('unattended.level', CronUpdateRunner::SECURITY) ->save(); $logger = new TestLogger(); diff --git a/tests/src/Kernel/StatusCheck/StatusCheckerTest.php b/tests/src/Kernel/StatusCheck/StatusCheckerTest.php index 9acec34a97..0f24bc7a9a 100644 --- a/tests/src/Kernel/StatusCheck/StatusCheckerTest.php +++ b/tests/src/Kernel/StatusCheck/StatusCheckerTest.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel\StatusCheck; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\automatic_updates\UpdateStage; use Drupal\automatic_updates\Validation\StatusChecker; @@ -212,7 +212,7 @@ class StatusCheckerTest extends AutomaticUpdatesKernelTestBase { // By default, updates will be enabled on cron. $this->assertInstanceOf(ConsoleUpdateStage::class, $stage); $this->config('automatic_updates.settings') - ->set('unattended.level', CronUpdateStage::DISABLED) + ->set('unattended.level', CronUpdateRunner::DISABLED) ->save(); $this->container->get(StatusChecker::class)->run(); $this->assertInstanceOf(UpdateStage::class, $stage); diff --git a/tests/src/Kernel/StatusCheck/VersionPolicyValidatorTest.php b/tests/src/Kernel/StatusCheck/VersionPolicyValidatorTest.php index d11bb0a3f4..c19a7fc380 100644 --- a/tests/src/Kernel/StatusCheck/VersionPolicyValidatorTest.php +++ b/tests/src/Kernel/StatusCheck/VersionPolicyValidatorTest.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel\StatusCheck; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\ConsoleUpdateStage; use Drupal\automatic_updates\UpdateStage; use Drupal\fixture_manipulator\ActiveFixtureManipulator; @@ -46,7 +46,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.1', NULL, "$metadata_dir/drupal.9.8.2.xml", - [CronUpdateStage::DISABLED, CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::DISABLED, CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [], ], // These three cases prove that updating from an unsupported minor version @@ -59,14 +59,14 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.1', NULL, "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], 'update from unsupported minor, cron enabled, minor updates forbidden' => [ '9.7.1', NULL, "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.'), t('See the <a href="/admin/reports/updates">available updates page</a> for available updates.'), @@ -76,7 +76,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.1', NULL, "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.'), t('Use the <a href="/admin/modules/update">update form</a> to update to a supported version.'), @@ -103,7 +103,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED, CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::DISABLED, CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [], ], // This case proves that updating from a dev snapshot is never allowed, @@ -112,7 +112,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0-dev', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED, CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::DISABLED, CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('Drupal cannot be automatically updated from the installed version, 9.8.0-dev, because automatic updates from a dev version to any other version are not supported.'), ], @@ -123,14 +123,14 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0-alpha1', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], 'alpha installed, cron enabled' => [ '9.8.0-alpha1', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('Drupal cannot be automatically updated during cron from its current version, 9.8.0-alpha1, because it is not a stable version.'), ], @@ -139,14 +139,14 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0-beta2', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], 'beta installed, cron enabled' => [ '9.8.0-beta2', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('Drupal cannot be automatically updated during cron from its current version, 9.8.0-beta2, because it is not a stable version.'), ], @@ -155,14 +155,14 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0-rc3', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], 'rc installed, cron enabled' => [ '9.8.0-rc3', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('Drupal cannot be automatically updated during cron from its current version, 9.8.0-rc3, because it is not a stable version.'), ], @@ -181,9 +181,9 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { * The path of the core release metadata to serve to the update system. * @param string[] $cron_modes * The modes for unattended updates. Can contain any of - * \Drupal\automatic_updates\CronUpdateStage::DISABLED, - * \Drupal\automatic_updates\CronUpdateStage::SECURITY, and - * \Drupal\automatic_updates\CronUpdateStage::ALL. + * \Drupal\automatic_updates\CronUpdateRunner::DISABLED, + * \Drupal\automatic_updates\CronUpdateRunner::SECURITY, and + * \Drupal\automatic_updates\CronUpdateRunner::ALL. * @param \Drupal\Core\StringTranslation\TranslatableMarkup[] $expected_validation_messages * The expected validation messages. * @param bool $allow_minor_updates @@ -230,21 +230,21 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0', '9.8.1-alpha1', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], 'update to beta, cron disabled' => [ '9.8.0', '9.8.1-beta2', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], 'update to rc, cron disabled' => [ '9.8.0', '9.8.1-rc3', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [], ], // This case proves that, if a stable release is installed, there is an @@ -255,7 +255,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.1', '9.8.2', "$metadata_dir/drupal.9.8.2.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron from 9.8.1 to 9.8.2 because 9.8.2 is not a security release.'), ], @@ -267,7 +267,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0', '9.8.1-alpha1', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron to the recommended version, 9.8.1-alpha1, because it is not a stable version.'), t('Drupal cannot be automatically updated during cron from 9.8.0 to 9.8.1-alpha1 because 9.8.1-alpha1 is not a security release.'), @@ -277,7 +277,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0', '9.8.1-beta2', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron to the recommended version, 9.8.1-beta2, because it is not a stable version.'), t('Drupal cannot be automatically updated during cron from 9.8.0 to 9.8.1-beta2 because 9.8.1-beta2 is not a security release.'), @@ -287,7 +287,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.8.0', '9.8.1-rc3', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron to the recommended version, 9.8.1-rc3, because it is not a stable version.'), t('Drupal cannot be automatically updated during cron from 9.8.0 to 9.8.1-rc3 because 9.8.1-rc3 is not a security release.'), @@ -300,7 +300,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.0', '9.8.1-alpha1', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron to the recommended version, 9.8.1-alpha1, because it is not a stable version.'), t('Drupal cannot be automatically updated from 9.7.0 to 9.8.1-alpha1 because automatic updates from one minor version to another are not supported during cron.'), @@ -311,7 +311,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.0', '9.8.1-beta2', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron to the recommended version, 9.8.1-beta2, because it is not a stable version.'), t('Drupal cannot be automatically updated from 9.7.0 to 9.8.1-beta2 because automatic updates from one minor version to another are not supported during cron.'), @@ -322,7 +322,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.0', '9.8.1-rc3', "$metadata_dir/drupal.9.8.1-extra.xml", - [CronUpdateStage::SECURITY], + [CronUpdateRunner::SECURITY], [ t('Drupal cannot be automatically updated during cron to the recommended version, 9.8.1-rc3, because it is not a stable version.'), t('Drupal cannot be automatically updated from 9.7.0 to 9.8.1-rc3 because automatic updates from one minor version to another are not supported during cron.'), @@ -340,7 +340,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.1', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::DISABLED], + [CronUpdateRunner::DISABLED], [ t('Drupal cannot be automatically updated from 9.7.1 to 9.8.1 because automatic updates from one minor version to another are not supported.'), ], @@ -349,7 +349,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.1', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.'), t('See the <a href="/admin/reports/updates">available updates page</a> for available updates.'), @@ -360,7 +360,7 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { '9.7.1', '9.8.1', "$metadata_dir/drupal.9.8.1-security.xml", - [CronUpdateStage::SECURITY, CronUpdateStage::ALL], + [CronUpdateRunner::SECURITY, CronUpdateRunner::ALL], [ t('The currently installed version of Drupal core, 9.7.1, is not in a supported minor version. Your site will not be automatically updated during cron until it is updated to a supported minor version.'), t('Use the <a href="/admin/modules/update">update form</a> to update to a supported version.'), @@ -382,9 +382,9 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase { * The path of the core release metadata to serve to the update system. * @param string[] $cron_modes * The modes for unattended updates. Can contain any of - * \Drupal\automatic_updates\CronUpdateStage::DISABLED, - * \Drupal\automatic_updates\CronUpdateStage::SECURITY, and - * \Drupal\automatic_updates\CronUpdateStage::ALL. + * \Drupal\automatic_updates\CronUpdateRunner::DISABLED, + * \Drupal\automatic_updates\CronUpdateRunner::SECURITY, and + * \Drupal\automatic_updates\CronUpdateRunner::ALL. * @param \Drupal\Core\StringTranslation\TranslatableMarkup[] $expected_validation_messages * The expected validation messages. * @param bool $allow_minor_updates diff --git a/tests/src/Kernel/StatusCheck/WindowsValidatorTest.php b/tests/src/Kernel/StatusCheck/WindowsValidatorTest.php index 69df70ce9d..e159a567c3 100644 --- a/tests/src/Kernel/StatusCheck/WindowsValidatorTest.php +++ b/tests/src/Kernel/StatusCheck/WindowsValidatorTest.php @@ -5,7 +5,7 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Kernel\StatusCheck; use ColinODell\PsrTestLogger\TestLogger; -use Drupal\automatic_updates\CronUpdateStage; +use Drupal\automatic_updates\CronUpdateRunner; use Drupal\automatic_updates\Validator\WindowsValidator; use Drupal\Core\Logger\RfcLogLevel; use Drupal\package_manager\ValidationResult; @@ -46,7 +46,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { ['administer software updates'], [ 'method' => 'web', - 'level' => CronUpdateStage::ALL, + 'level' => CronUpdateRunner::ALL, ], [ ValidationResult::createError([ @@ -58,7 +58,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { [], [ 'method' => 'web', - 'level' => CronUpdateStage::ALL, + 'level' => CronUpdateRunner::ALL, ], [ ValidationResult::createError([ @@ -70,7 +70,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { ['administer software updates'], [ 'method' => 'console', - 'level' => CronUpdateStage::ALL, + 'level' => CronUpdateRunner::ALL, ], [], ], @@ -78,7 +78,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { [], [ 'method' => 'console', - 'level' => CronUpdateStage::ALL, + 'level' => CronUpdateRunner::ALL, ], [], ], @@ -86,7 +86,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { ['administer software updates'], [ 'method' => 'web', - 'level' => CronUpdateStage::DISABLED, + 'level' => CronUpdateRunner::DISABLED, ], [], ], @@ -94,7 +94,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { [], [ 'method' => 'web', - 'level' => CronUpdateStage::DISABLED, + 'level' => CronUpdateRunner::DISABLED, ], [], ], @@ -144,7 +144,7 @@ class WindowsValidatorTest extends AutomaticUpdatesKernelTestBase { $this->assertCheckerResultsFromManager([], TRUE); // If unattended updates are enabled, ensure that they will succeed. - if ($unattended_update_settings['level'] !== CronUpdateStage::DISABLED) { + if ($unattended_update_settings['level'] !== CronUpdateRunner::DISABLED) { $logger->reset(); $this->getStageFixtureManipulator()->setCorePackageVersion('9.8.1'); $this->runConsoleUpdateStage(); -- GitLab