function TemplateProjectTestBase::setUpstreamCoreVersion

Sets the version of Drupal core to which the test site will be updated.

Parameters

string $version: The Drupal core version to set.

File

core/modules/package_manager/tests/src/Build/TemplateProjectTestBase.php, line 108

Class

TemplateProjectTestBase
Base class for tests which create a test site from a core project template.

Namespace

Drupal\Tests\package_manager\Build

Code

protected function setUpstreamCoreVersion(string $version) : void {
    $this->createVendorRepository([
        'drupal/core' => $version,
        'drupal/core-dev' => $version,
        'drupal/core-dev-pinned' => $version,
        'drupal/core-recommended' => $version,
        'drupal/core-composer-scaffold' => $version,
        'drupal/core-project-message' => $version,
        'drupal/core-vendor-hardening' => $version,
    ]);
    // Change the \Drupal::VERSION constant and put placeholder text in the
    // README so we can ensure that we really updated to the correct version. We
    // also change the default site configuration files so we can ensure that
    // these are updated as well, despite `sites/default` being write-protected.
    // @see ::assertUpdateSuccessful()
    // @see ::createTestProject()
    $core_dir = $this->getWorkspaceDrupalRoot() . '/core';
    Composer::setDrupalVersion($this->getWorkspaceDrupalRoot(), $version);
    file_put_contents("{$core_dir}/README.txt", "Placeholder for Drupal core {$version}.");
    foreach ([
        'default.settings.php',
        'default.services.yml',
    ] as $file) {
        file_put_contents("{$core_dir}/assets/scaffold/files/{$file}", "# This is part of Drupal {$version}.\n", FILE_APPEND);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.