You are here

protected function CoreUpdateTest::createTestSite in Automatic Updates 8.2

Uses our already-installed dependencies to build a test site to update.

Parameters

string $template: The template project from which to build the test site. Can be 'drupal/recommended-project' or 'drupal/legacy-project'.

Overrides UpdateTestBase::createTestSite

3 calls to CoreUpdateTest::createTestSite()
CoreUpdateTest::testApi in tests/src/Build/CoreUpdateTest.php
Tests an end-to-end core update via the API.
CoreUpdateTest::testCron in tests/src/Build/CoreUpdateTest.php
Tests an end-to-end core update via cron.
CoreUpdateTest::testUi in tests/src/Build/CoreUpdateTest.php
Tests an end-to-end core update via the UI.

File

tests/src/Build/CoreUpdateTest.php, line 15

Class

CoreUpdateTest
Tests an end-to-end update of Drupal core.

Namespace

Drupal\Tests\automatic_updates\Build

Code

protected function createTestSite(string $template) : void {

  // Build the test site and alter its copy of core so that it thinks it's
  // running Drupal 9.8.0, which will never actually exist in the real world.
  // Then, prepare a secondary copy of the core code base, masquerading as
  // Drupal 9.8.1, which will be the version of core we update to. These two
  // versions are referenced in the fake release metadata in our fake release
  // metadata (see fixtures/release-history/drupal.0.0.xml).
  parent::createTestSite($template);
  $this
    ->setCoreVersion($this
    ->getWebRoot() . '/core', '9.8.0');
  $this
    ->alterPackage($this
    ->getWorkspaceDirectory(), $this
    ->getConfigurationForUpdate('9.8.1'));

  // Install Drupal and ensure it's using the fake release metadata to fetch
  // information about available updates.
  $this
    ->installQuickStart('minimal');
  $this
    ->setReleaseMetadata([
    'drupal' => '9.8.1-security',
  ]);
  $this
    ->formLogin($this->adminUsername, $this->adminPassword);
  $this
    ->installModules([
    'automatic_updates',
    'automatic_updates_test',
    'update_test',
  ]);

  // Ensure that Drupal thinks we are running 9.8.0, then refresh information
  // about available updates.
  $this
    ->assertCoreVersion('9.8.0');
  $this
    ->checkForUpdates();

  // Ensure that an update to 9.8.1 is available.
  $this
    ->visit('/admin/modules/automatic-update');
  $this
    ->getMink()
    ->assertSession()
    ->pageTextContains('9.8.1');
}