function ComposerIntegrationTest::testAllCoreComponentsReplaced
Same name in other branches
- 9 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testAllCoreComponentsReplaced()
- 10 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testAllCoreComponentsReplaced()
Tests core's composer.json replace section.
Verify that all core components are also listed in the 'replace' section of core's composer.json.
File
-
core/
tests/ Drupal/ Tests/ ComposerIntegrationTest.php, line 96
Class
- ComposerIntegrationTest
- Tests Composer integration.
Namespace
Drupal\TestsCode
public function testAllCoreComponentsReplaced() : void {
// Assemble a path to core components.
$components_path = $this->root . '/core/lib/Drupal/Component';
// Grab the 'replace' section of the core composer.json file.
$json = json_decode(file_get_contents($this->root . '/core/composer.json'), FALSE);
$composer_replace_packages = (array) $json->replace;
// Get a list of all the composer.json files in the components path.
$components_composer_json_files = [];
$composer_json_finder = new Finder();
$composer_json_finder->name('composer.json')
->in($components_path)
->ignoreUnreadableDirs();
foreach ($composer_json_finder->getIterator() as $composer_json) {
$components_composer_json_files[$composer_json->getPathname()] = [
$composer_json->getPathname(),
];
}
$this->assertNotEmpty($components_composer_json_files);
$this->assertCount(count($composer_replace_packages), $components_composer_json_files);
// Assert that each core components has a corresponding 'replace' in
// composer.json.
foreach ($components_composer_json_files as $components_composer_json_file) {
$json = json_decode(file_get_contents(reset($components_composer_json_file)), FALSE);
$component_name = $json->name;
$this->assertArrayHasKey($component_name, $composer_replace_packages, 'Unable to find ' . $component_name . ' in replace list of composer.json');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.