function OverlapWithTopLevelDependenciesTest::testOverlapWithTemplateProject

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Composer/Generator/OverlapWithTopLevelDependenciesTest.php \Drupal\Tests\Composer\Generator\OverlapWithTopLevelDependenciesTest::testOverlapWithTemplateProject()
  2. 10 core/tests/Drupal/Tests/Composer/Generator/OverlapWithTopLevelDependenciesTest.php \Drupal\Tests\Composer\Generator\OverlapWithTopLevelDependenciesTest::testOverlapWithTemplateProject()
  3. 11.x core/tests/Drupal/Tests/Composer/Generator/OverlapWithTopLevelDependenciesTest.php \Drupal\Tests\Composer\Generator\OverlapWithTopLevelDependenciesTest::testOverlapWithTemplateProject()

Tests top level and core-recommended dependencies do not overlap.

@dataProvider templateProjectPathProvider

Parameters

string $template_project_path: The path of the project template to test.

File

core/tests/Drupal/Tests/Composer/Generator/OverlapWithTopLevelDependenciesTest.php, line 36

Class

OverlapWithTopLevelDependenciesTest
Tests DrupalCoreRecommendedBuilder.

Namespace

Drupal\Tests\Composer\Generator

Code

public function testOverlapWithTemplateProject($template_project_path) {
    $root = dirname(__DIR__, 6);
    // Read template project composer.json.
    $top_level_composer_json = json_decode(file_get_contents("{$root}/{$template_project_path}/composer.json"), TRUE);
    // Read drupal/core-recommended composer.json.
    $core_recommended_composer_json = json_decode(file_get_contents("{$root}/composer/Metapackage/CoreRecommended/composer.json"), TRUE);
    // Fail if any required project in the require section of the template
    // project also exists in core/recommended.
    foreach ($top_level_composer_json['require'] as $project => $version_constraint) {
        $this->assertArrayNotHasKey($project, $core_recommended_composer_json['require'], "Pinned project {$project} is also a top-level dependency of {$template_project_path}. This can expose a Composer bug. See https://www.drupal.org/project/drupal/issues/3134648 and https://github.com/composer/composer/issues/8882");
    }
}

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