Mercurial > hg > isophonics-drupal-site
diff core/tests/Drupal/Tests/Component/DrupalComponentTest.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line diff
--- a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php Mon Apr 23 09:33:26 2018 +0100 +++ b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php Mon Apr 23 09:46:53 2018 +0100 @@ -33,6 +33,34 @@ } /** + * Tests LICENSE.txt is present and has the correct content. + * + * @param $component_path + * The path to the component. + * @dataProvider \Drupal\Tests\Component\DrupalComponentTest::getComponents + */ + public function testComponentLicence($component_path) { + $this->assertFileExists($component_path . DIRECTORY_SEPARATOR . 'LICENSE.txt'); + $this->assertSame('e84dac1d9fbb5a4a69e38654ce644cea769aa76b', hash_file('sha1', $component_path . DIRECTORY_SEPARATOR . 'LICENSE.txt')); + } + + /** + * Data provider. + * + * @return array + */ + public function getComponents() { + $root_component_path = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))) . '/lib/Drupal/Component'; + $component_paths = []; + foreach (new \DirectoryIterator($root_component_path) as $file) { + if ($file->isDir() && !$file->isDot()) { + $component_paths[$file->getBasename()] = [$file->getPathname()]; + } + } + return $component_paths; + } + + /** * Searches a directory recursively for PHP classes. * * @param string $dir