You are here

protected function CoreUpdateTest::getConfigurationForUpdate in Automatic Updates 8.2

Returns composer.json changes that are needed to update core.

This will clone the following packages into temporary directories:

  • drupal/core
  • drupal/core-recommended
  • drupal/core-project-message
  • drupal/core-composer-scaffold

The cloned packages will be assigned the given version number, and the test site's composer.json will use the clones as path repositories.

Parameters

string $version: The version of core we will be updating to.

Return value

array The changes to merge into the test site's composer.json.

1 call to CoreUpdateTest::getConfigurationForUpdate()
CoreUpdateTest::createTestSite in tests/src/Build/CoreUpdateTest.php
Uses our already-installed dependencies to build a test site to update.

File

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

Class

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

Namespace

Drupal\Tests\automatic_updates\Build

Code

protected function getConfigurationForUpdate(string $version) : array {
  $repositories = [];

  // Create a fake version of core with the given version number, and change
  // its README so that we can actually be certain that we update to this
  // fake version.
  $dir = $this
    ->copyPackage($this
    ->getWebRoot() . '/core');
  $this
    ->setCoreVersion($dir, $version);
  file_put_contents("{$dir}/README.txt", "Placeholder for Drupal core {$version}.");
  $repositories['drupal/core'] = $this
    ->createPathRepository($dir);
  $drupal_root = $this
    ->getDrupalRoot();

  // Create a fake version of drupal/core-recommended which itself requires
  // the fake version of core we just created.
  $dir = $this
    ->copyPackage("{$drupal_root}/composer/Metapackage/CoreRecommended");
  $this
    ->alterPackage($dir, [
    'require' => [
      'drupal/core' => $version,
    ],
    'version' => $version,
  ]);
  $repositories['drupal/core-recommended'] = $this
    ->createPathRepository($dir);

  // Create a fake version of drupal/core-project-message.
  $dir = $this
    ->copyPackage("{$drupal_root}/composer/Plugin/ProjectMessage");
  $this
    ->alterPackage($dir, [
    'version' => $version,
  ]);
  $repositories['drupal/core-project-message'] = $this
    ->createPathRepository($dir);

  // Create a fake version of drupal/core-composer-scaffold.
  $dir = $this
    ->copyPackage("{$drupal_root}/composer/Plugin/Scaffold");
  $this
    ->alterPackage($dir, [
    'version' => $version,
  ]);
  $repositories['drupal/core-composer-scaffold'] = $this
    ->createPathRepository($dir);

  // Create a fake version of drupal/core-vendor-hardening.
  $dir = $this
    ->copyPackage("{$drupal_root}/composer/Plugin/VendorHardening");
  $this
    ->alterPackage($dir, [
    'version' => $version,
  ]);
  $repositories['drupal/core-vendor-hardening'] = $this
    ->createPathRepository($dir);
  return [
    'repositories' => $repositories,
  ];
}