function ComposerIntegrationTest::testComposerTilde
Same name in other branches
- 9 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerTilde()
- 8.9.x core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerTilde()
- 10 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerTilde()
Tests composer.json versions.
@dataProvider providerTestComposerJson
Parameters
string $path: Path to a composer.json to test.
File
-
core/
tests/ Drupal/ Tests/ ComposerIntegrationTest.php, line 55
Class
- ComposerIntegrationTest
- Tests Composer integration.
Namespace
Drupal\TestsCode
public function testComposerTilde(string $path) : void {
if (str_ends_with($path, 'composer/Metapackage/CoreRecommended/composer.json')) {
$this->markTestSkipped("{$path} has tilde");
}
$content = json_decode(file_get_contents($path), TRUE);
$composer_keys = array_intersect([
'require',
'require-dev',
], array_keys($content));
if (empty($composer_keys)) {
$this->markTestSkipped("{$path} has no keys to test");
}
foreach ($composer_keys as $composer_key) {
foreach ($content[$composer_key] as $dependency => $version) {
// We allow tildes if the dependency is a Symfony component.
// @see https://www.drupal.org/node/2887000
if (str_starts_with($dependency, 'symfony/')) {
continue;
}
$this->assertStringNotContainsString('~', $version, "Dependency {$dependency} in {$path} contains a tilde, use a caret.");
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.