diff --git a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php index 9d2608701d56e4da4bd150d9a3abe21ae4128fac..0c3874ce0f2215f63cbfa07230d9ccde9d2f4325 100644 --- a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php +++ b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php @@ -120,12 +120,12 @@ abstract class AutomaticUpdatesFunctionalTestBase extends BrowserTestBase { } /** - * Sets the current (running) version of core, as known to the Update module. + * Mocks the current (running) version of core, as known to the Update module. * * @param string $version - * The current version of core. + * The version of core to mock. */ - protected function setCoreVersion(string $version): void { + protected function mockActiveCoreVersion(string $version): void { $this->config('update_test.settings') ->set('system_info.#all.version', $version) ->save(); diff --git a/tests/src/Functional/AvailableUpdatesReportTest.php b/tests/src/Functional/AvailableUpdatesReportTest.php index e11d6c8678fde8be0934770cd1df765ea0b287e1..5b9241285ba9cc52e892e641db86d2a1f18530a9 100644 --- a/tests/src/Functional/AvailableUpdatesReportTest.php +++ b/tests/src/Functional/AvailableUpdatesReportTest.php @@ -52,14 +52,14 @@ class AvailableUpdatesReportTest extends AutomaticUpdatesFunctionalTestBase { $this->config('automatic_updates.settings')->set('allow_core_minor_updates', TRUE)->save(); $fixture_directory = __DIR__ . '/../../../package_manager/tests/fixtures/release-history'; $this->setReleaseMetadata("$fixture_directory/drupal.9.8.1-security.xml"); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $assert->pageTextContains('Security update required! Update now'); $assert->elementAttributeContains('named', ['link', 'Update now'], 'href', $form_url); $this->assertVersionLink('9.8.1', $form_url); $this->setReleaseMetadata("$fixture_directory/drupal.9.8.2-older-sec-release.xml"); - $this->setCoreVersion('9.7.0'); + $this->mockActiveCoreVersion('9.7.0'); $this->checkForUpdates(); $assert->pageTextContains('Security update required! Update now'); diff --git a/tests/src/Functional/StatusCheckTest.php b/tests/src/Functional/StatusCheckTest.php index b5bb7b9019342f3ffc5f5710a480e25358d3314d..d915ae10e075769bb46ad0de329009f42f4bd757 100644 --- a/tests/src/Functional/StatusCheckTest.php +++ b/tests/src/Functional/StatusCheckTest.php @@ -68,7 +68,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase { protected function setUp(): void { parent::setUp(); $this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.1-security.xml'); - $this->setCoreVersion('9.8.1'); + $this->mockActiveCoreVersion('9.8.1'); $this->reportViewerUser = $this->createUser([ 'administer site configuration', @@ -479,7 +479,7 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase { // The current release is 9.8.1 (see ::setUp()), so ensure we're on an older // version. - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); // Flag a validation error, which will be displayed in the messages area. $results = [$this->createValidationResult(SystemManager::REQUIREMENT_ERROR)]; diff --git a/tests/src/Functional/UpdateLockTest.php b/tests/src/Functional/UpdateLockTest.php index 2fd681da2754ecb83015bc776d290a544987874b..165746ad62d6b07dbc83fbf307917883370784cf 100644 --- a/tests/src/Functional/UpdateLockTest.php +++ b/tests/src/Functional/UpdateLockTest.php @@ -49,7 +49,7 @@ class UpdateLockTest extends AutomaticUpdatesFunctionalTestBase { ->setReadyToCommit(); $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $permissions = ['administer software updates']; $user_1 = $this->createUser($permissions); diff --git a/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php b/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php index d5990456919a028128e4fa02c09c52442dbca982..f5be5aa0352868d614a23d262db9bebc75c2080c 100644 --- a/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php +++ b/tests/src/Functional/UpdaterFormNoRecommendedReleaseMessageTest.php @@ -85,7 +85,7 @@ class UpdaterFormNoRecommendedReleaseMessageTest extends AutomaticUpdatesFunctio */ public function testMessages(string $release_metadata, string $installed_version, bool $updates_available, string $expected_message_type): void { $this->setReleaseMetadata($release_metadata); - $this->setCoreVersion($installed_version); + $this->mockActiveCoreVersion($installed_version); $this->checkForUpdates(); $this->drupalGet('/admin/reports/updates/update'); diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index 0e6330dd32ae3ed889def931daae62f141d8661f..f8350d13b143e08cd266bfc17aa20c397a325039 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -108,7 +108,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * @dataProvider providerUpdateFormReferringUrl */ public function testFormNotDisplayedIfAlreadyCurrent(string $update_form_url): void { - $this->setCoreVersion('9.8.1'); + $this->mockActiveCoreVersion('9.8.1'); $this->checkForUpdates(); $this->drupalGet($update_form_url); @@ -141,7 +141,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $page = $this->getSession()->getPage(); $this->drupalPlaceBlock('local_tasks_block', ['primary' => TRUE]); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); // Navigate to the automatic updates form. @@ -165,7 +165,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { // Check the form when there is an update in the next minor only. $this->config('automatic_updates.settings')->set('allow_core_minor_updates', TRUE)->save(); - $this->setCoreVersion('9.7.0'); + $this->mockActiveCoreVersion('9.7.0'); $page->clickLink('Check manually'); $this->checkForMetaRefresh(); $this->checkReleaseTable('#edit-next-minor-1', '.update-update-recommended', '9.8.1', TRUE, 'Latest version of Drupal 9.8 (next minor) (Release notes):'); @@ -194,7 +194,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $this->assertReleaseNotesLink(9, 8, '#edit-next-minor-1'); $assert_minor_update_help(); - $this->setCoreVersion('9.7.1'); + $this->mockActiveCoreVersion('9.7.1'); $page->clickLink('Check manually'); $this->checkForMetaRefresh(); $assert_session->pageTextContainsOnce('Currently installed: 9.7.1 (Update available)'); @@ -207,7 +207,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { // are visible. $this->config('automatic_updates.settings')->set('allow_core_minor_updates', TRUE)->save(); $this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.10.0.0.xml'); - $this->setCoreVersion('9.5.0'); + $this->mockActiveCoreVersion('9.5.0'); $page->clickLink('Check manually'); $this->checkForMetaRefresh(); $assert_session->pageTextNotContains('10.0.0'); @@ -221,7 +221,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { // Check that if installed version is unsupported and minor updates are // enabled then updates in the next minors are visible. - $this->setCoreVersion('9.4.0'); + $this->mockActiveCoreVersion('9.4.0'); $page->clickLink('Check manually'); $this->checkForMetaRefresh(); $assert_session->pageTextNotContains('10.0.0'); @@ -251,7 +251,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { */ public function testStatusCheckFailureWhenNoUpdateExists() { $assert_session = $this->assertSession(); - $this->setCoreVersion('9.8.1'); + $this->mockActiveCoreVersion('9.8.1'); $message = "You've not experienced Shakespeare until you have read him in the original Klingon."; $result = ValidationResult::createError([$message]); TestSubscriber1::setTestResult([$result], StatusCheckEvent::class); @@ -266,7 +266,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { */ public function testNextMinorPreRelease(): void { $this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.0-beta1.xml'); - $this->setCoreVersion('9.7.0'); + $this->mockActiveCoreVersion('9.7.0'); $this->config('automatic_updates.settings') ->set('allow_core_minor_updates', TRUE) ->save(); @@ -326,7 +326,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $session->reload(); $assert_session->pageTextContainsOnce($cached_message); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); // Set up a new fake error. Use an error with multiple messages so we can @@ -397,7 +397,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $session = $this->getSession(); $assert_session = $this->assertSession(); $page = $session->getPage(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $this->drupalGet('/admin/modules/automatic-update'); @@ -436,7 +436,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * @dataProvider providerUpdateFormReferringUrl */ public function testMinorVersionUpdateNotSupported(string $update_form_url): void { - $this->setCoreVersion('9.7.1'); + $this->mockActiveCoreVersion('9.7.1'); $this->checkForUpdates(); $this->drupalGet($update_form_url); @@ -460,7 +460,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $this->drupalGet('/admin/modules/update'); @@ -585,7 +585,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { (new StageFixtureManipulator()) ->setCorePackageVersion('9.8.1') ->setReadyToCommit(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $this->container->get('theme_installer')->install(['automatic_updates_theme_with_updates']); $cached_message = $this->setAndAssertCachedMessage(); @@ -706,7 +706,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ->setCorePackageVersion('9.8.1') ->setReadyToCommit(); $assert_session = $this->assertSession(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $state = $this->container->get('state'); $state->set('system.maintenance_mode', $maintenance_mode_on); @@ -769,7 +769,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ->setCorePackageVersion('9.8.1') ->setReadyToCommit(); $assert_session = $this->assertSession(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $page = $this->getSession()->getPage(); // Navigate to the automatic updates form. @@ -849,7 +849,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ->setCorePackageVersion('9.8.1') ->setReadyToCommit(); $assert_session = $this->assertSession(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $state = $this->container->get('state'); $state->set('system.maintenance_mode', $maintenance_mode_on); @@ -874,7 +874,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { (new StageFixtureManipulator()) ->setCorePackageVersion('9.8.1') ->setReadyToCommit(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $page = $this->getSession()->getPage(); @@ -911,7 +911,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $session = $this->getSession(); $assert_session = $this->assertSession(); $page = $session->getPage(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $this->drupalGet('/admin/modules/update'); @@ -938,7 +938,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $session = $this->getSession(); $assert_session = $this->assertSession(); $page = $session->getPage(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $this->drupalGet('/admin/modules/automatic-update'); $page->pressButton('Update to 9.8.1'); @@ -968,7 +968,7 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { public function testContinueOnWarning(): void { $session = $this->getSession(); - $this->setCoreVersion('9.8.0'); + $this->mockActiveCoreVersion('9.8.0'); $this->checkForUpdates(); $this->drupalGet('/admin/modules/automatic-update'); $session->getPage()->pressButton('Update to 9.8.1');