diff --git a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php index 864646457118088b1c7bc90c025fae8f07a9b859..901d327b6a924e12ac1dbf013243b0dea0d7f951 100644 --- a/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php +++ b/tests/src/Functional/AutomaticUpdatesFunctionalTestBase.php @@ -33,18 +33,6 @@ abstract class AutomaticUpdatesFunctionalTestBase extends BrowserTestBase { 'package_manager_bypass', ]; - /** - * Set the core update version. - * - * @param string $version - * The core version. - */ - protected function setCoreUpdate(string $version): void { - $stage_manipulator = new StageFixtureManipulator(); - $stage_manipulator->setCorePackageVersion($version) - ->setReadyToCommit(); - } - /** * The service IDs of any validators to disable. * diff --git a/tests/src/Functional/StatusCheckTest.php b/tests/src/Functional/StatusCheckTest.php index e7eb188a520ca895a582cdad7f46a5e829254f49..5fcde2d67471461e34ef6b4a949c5698e45d807f 100644 --- a/tests/src/Functional/StatusCheckTest.php +++ b/tests/src/Functional/StatusCheckTest.php @@ -11,6 +11,7 @@ use Drupal\automatic_updates_test\Datetime\TestTime; use Drupal\automatic_updates_test\EventSubscriber\TestSubscriber1; use Drupal\automatic_updates_test2\EventSubscriber\TestSubscriber2; use Drupal\Core\Url; +use Drupal\fixture_manipulator\StageFixtureManipulator; use Drupal\package_manager\Event\StatusCheckEvent; use Drupal\package_manager_test_validation\EventSubscriber\TestSubscriber; use Drupal\system\SystemManager; @@ -469,6 +470,9 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase { * Tests that stored validation results are deleted after an update. */ public function testStoredResultsClearedAfterUpdate(): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalLogin($this->checkerRunnerUser); @@ -500,7 +504,6 @@ class StatusCheckTest extends AutomaticUpdatesFunctionalTestBase { // status check (without storing the results), and the checker is no // longer raising an error. $this->drupalGet('/admin/modules/update'); - $this->setCoreUpdate('9.8.1'); $assert_session->buttonExists('Update to 9.8.1'); // Ensure that the previous results are still displayed on another admin // page, to confirm that the updater form is not discarding the previous diff --git a/tests/src/Functional/UpdateLockTest.php b/tests/src/Functional/UpdateLockTest.php index 5512da72539f0d54b55f552b1c554c972d55a3fc..2fd681da2754ecb83015bc776d290a544987874b 100644 --- a/tests/src/Functional/UpdateLockTest.php +++ b/tests/src/Functional/UpdateLockTest.php @@ -4,6 +4,8 @@ declare(strict_types = 1); namespace Drupal\Tests\automatic_updates\Functional; +use Drupal\fixture_manipulator\StageFixtureManipulator; + /** * Tests that only one Automatic Update operation can be performed at a time. * @@ -42,6 +44,9 @@ class UpdateLockTest extends AutomaticUpdatesFunctionalTestBase { * Tests that only user who started an update can continue through it. */ public function testLock(): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); $this->setCoreVersion('9.8.0'); @@ -53,7 +58,6 @@ class UpdateLockTest extends AutomaticUpdatesFunctionalTestBase { // We should be able to get partway through an update without issue. $this->drupalLogin($user_1); $this->drupalGet('/admin/modules/update'); - $this->setCoreUpdate('9.8.1'); $page->pressButton('Update'); $this->checkForMetaRefresh(); $this->assertUpdateReady('9.8.1'); diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index 4288b6cae78942354cde9687757b5b222f963e6f..7bfab83517a40629004ef6a5b03cfa1ff29ea597 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -452,6 +452,9 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * Tests deleting an existing update. */ public function testDeleteExistingUpdate(): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $conflict_message = 'Cannot begin an update because another Composer operation is currently in progress.'; $cancelled_message = 'The update was successfully cancelled.'; @@ -461,7 +464,6 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $this->checkForUpdates(); $this->drupalGet('/admin/modules/update'); - $this->setCoreUpdate('9.8.1'); $page->pressButton('Update to 9.8.1'); $this->checkForMetaRefresh(); $this->assertUpdateStagedTimes(1); @@ -580,6 +582,9 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * @requires PHP >= 8.0 */ public function testStagedDatabaseUpdates(bool $maintenance_mode_on): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $this->setCoreVersion('9.8.0'); $this->checkForUpdates(); $this->container->get('theme_installer')->install(['automatic_updates_theme_with_updates']); @@ -598,7 +603,6 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $page = $this->getSession()->getPage(); $this->drupalGet('/admin/modules/update'); - $this->setCoreUpdate('9.8.1'); // The warning should be visible. $assert_session = $this->assertSession(); $assert_session->pageTextContains(reset($messages)); @@ -698,6 +702,9 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * @dataProvider providerSuccessfulUpdate */ public function testSuccessfulUpdate(string $update_form_url, bool $maintenance_mode_on): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $assert_session = $this->assertSession(); $this->setCoreVersion('9.8.0'); $this->checkForUpdates(); @@ -707,7 +714,6 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $cached_message = $this->setAndAssertCachedMessage(); $this->drupalGet($update_form_url); - $this->setCoreUpdate('9.8.1'); $assert_session->pageTextNotContains($cached_message); $page->pressButton('Update to 9.8.1'); $this->checkForMetaRefresh(); @@ -759,13 +765,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * @requires PHP >= 8.0 */ public function testStatusCheckerRunAfterUpdate(bool $has_database_updates) { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $assert_session = $this->assertSession(); $this->setCoreVersion('9.8.0'); $this->checkForUpdates(); $page = $this->getSession()->getPage(); // Navigate to the automatic updates form. $this->drupalGet('/admin/modules/update'); - $this->setCoreUpdate('9.8.1'); $page->pressButton('Update to 9.8.1'); $this->checkForMetaRefresh(); $this->assertUpdateStagedTimes(1); @@ -837,6 +845,9 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * @dataProvider providerUpdateCompleteMessage */ public function testUpdateCompleteMessage(bool $maintenance_mode_on): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $assert_session = $this->assertSession(); $this->setCoreVersion('9.8.0'); $this->checkForUpdates(); @@ -845,7 +856,6 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $page = $this->getSession()->getPage(); $this->drupalGet('/admin/modules/automatic-update'); - $this->setCoreUpdate('9.8.1'); $page->pressButton('Update to 9.8.1'); $this->checkForMetaRefresh(); // Confirm that the site was put into maintenance mode if needed. @@ -861,12 +871,14 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { * Tests what happens when a staged update is deleted without being destroyed. */ public function testStagedUpdateDeletedImproperly(): void { + (new StageFixtureManipulator()) + ->setCorePackageVersion('9.8.1') + ->setReadyToCommit(); $this->setCoreVersion('9.8.0'); $this->checkForUpdates(); $page = $this->getSession()->getPage(); $this->drupalGet('/admin/modules/update'); - $this->setCoreUpdate('9.8.1'); $page->pressButton('Update to 9.8.1'); $this->checkForMetaRefresh(); $this->assertUpdateStagedTimes(1);