X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FComposerIntegrationTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FComposerIntegrationTest.php;h=b56849d86313823c10dc84a49484a6a0e26121c1;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=a64804cf8b8f74ee0dc7658ef761901838305359;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/tests/Drupal/Tests/ComposerIntegrationTest.php b/web/core/tests/Drupal/Tests/ComposerIntegrationTest.php index a64804cf8..b56849d86 100644 --- a/web/core/tests/Drupal/Tests/ComposerIntegrationTest.php +++ b/web/core/tests/Drupal/Tests/ComposerIntegrationTest.php @@ -47,6 +47,7 @@ class ComposerIntegrationTest extends UnitTestCase { $this->root . '/core/lib/Drupal/Component/Annotation', $this->root . '/core/lib/Drupal/Component/Assertion', $this->root . '/core/lib/Drupal/Component/Bridge', + $this->root . '/core/lib/Drupal/Component/ClassFinder', $this->root . '/core/lib/Drupal/Component/Datetime', $this->root . '/core/lib/Drupal/Component/DependencyInjection', $this->root . '/core/lib/Drupal/Component/Diff', @@ -88,6 +89,51 @@ class ComposerIntegrationTest extends UnitTestCase { $this->assertSame($content_hash, $lock['content-hash']); } + /** + * Tests composer.json versions. + * + * @param string $path + * Path to a composer.json to test. + * + * @dataProvider providerTestComposerJson + */ + 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->assertFalse(strpos($version, '~'), "Dependency $dependency in $path contains a tilde, use a caret."); + } + } + } + + /** + * Data provider for all the composer.json provided by Drupal core. + * + * @return array + */ + public function providerTestComposerJson() { + $root = realpath(__DIR__ . '/../../../../'); + $tests = [[$root . '/composer.json']]; + $directory = new \RecursiveDirectoryIterator($root . '/core'); + $iterator = new \RecursiveIteratorIterator($directory); + /** @var \SplFileInfo $file */ + foreach ($iterator as $file) { + if ($file->getFilename() === 'composer.json' && strpos($file->getPath(), 'core/modules/system/tests/fixtures/HtaccessTest') === FALSE) { + $tests[] = [$file->getRealPath()]; + } + } + return $tests; + } + /** * Tests core's composer.json replace section. *