function ComposerIntegrationTest::testComposerTilde
Same name in other branches
- 9 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerTilde()
- 10 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testComposerTilde()
- 11.x 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 46
Class
- ComposerIntegrationTest
- Tests Composer integration.
Namespace
Drupal\TestsCode
public function testComposerTilde($path) {
$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 (strpos($dependency, 'symfony/') === 0) {
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.