function ComponentsIsolatedBuildTest::addExpectedRepositories

Same name in other branches
  1. 9 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 75

Class

ComponentsIsolatedBuildTest
Try to install dependencies per component, using Composer.

Namespace

Drupal\BuildTests\Composer\Component

Code

protected function addExpectedRepositories(string $working_dir) : void {
    foreach ($this->provideComponentPaths() as $path) {
        $path = $path[0];
        $package_name = 'drupal/core' . strtolower(preg_replace('/[A-Z]/', '-$0', substr($path, 1)));
        $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.