function ComponentsIsolatedBuildTest::addExpectedRepositories

Same name in other branches
  1. 10 core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php \Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest::addExpectedRepositories()
  2. 11.x core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php \Drupal\BuildTests\Composer\Component\ComponentsIsolatedBuildTest::addExpectedRepositories()

Adds expected repositories as path repositories to package under test.

Parameters

string $working_dir: The working directory.

1 call to ComponentsIsolatedBuildTest::addExpectedRepositories()
ComponentsIsolatedBuildTest::testComponentComposerJson in core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php
Test whether components' composer.json can be installed in isolation.

File

core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php, line 70

Class

ComponentsIsolatedBuildTest
Try to install dependencies per component, using Composer.

Namespace

Drupal\BuildTests\Composer\Component

Code

protected function addExpectedRepositories(string $working_dir) : void {
    $repo_paths = [
        'Render' => 'drupal/core-render',
        'Utility' => 'drupal/core-utility',
    ];
    foreach ($repo_paths as $path => $package_name) {
        $path_repo = $this->getWorkingPath() . static::$componentsPath . '/' . $path;
        $repo_name = strtolower($path);
        // Add path repositories with the current version number to the current
        // package under test.
        $drupal_version = Composer::drupalVersionBranch();
        $this->executeCommand("composer config repositories.{$repo_name} " . "'{\"type\": \"path\",\"url\": \"{$path_repo}\",\"options\": {\"versions\": {\"{$package_name}\": \"{$drupal_version}\"}}}' --working-dir={$working_dir}");
    }
}

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