You are here

private function CoreUpdateTest::setCoreVersion in Automatic Updates 8.2

Modifies a Drupal core code base to set its version.

Parameters

string $dir: The directory of the Drupal core code base.

string $version: The version number to set.

2 calls to CoreUpdateTest::setCoreVersion()
CoreUpdateTest::createTestSite in tests/src/Build/CoreUpdateTest.php
Uses our already-installed dependencies to build a test site to update.
CoreUpdateTest::getConfigurationForUpdate in tests/src/Build/CoreUpdateTest.php
Returns composer.json changes that are needed to update core.

File

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

Class

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

Namespace

Drupal\Tests\automatic_updates\Build

Code

private function setCoreVersion(string $dir, string $version) : void {
  $this
    ->alterPackage($dir, [
    'version' => $version,
  ]);
  $drupal_php = "{$dir}/lib/Drupal.php";
  $this
    ->assertIsWritable($drupal_php);
  $code = file_get_contents($drupal_php);
  $code = preg_replace("/const VERSION = '([0-9]+\\.?){3}(-dev)?';/", "const VERSION = '{$version}';", $code);
  file_put_contents($drupal_php, $code);
}