X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FComponent%2FDrupalComponentTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FComponent%2FDrupalComponentTest.php;h=6b08cd94eb49eabdce57c54e8043a64e835a58d2;hp=03d39d3f1540a634a6a1be004e907aa2fe8303ce;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php index 03d39d3f1..6b08cd94e 100644 --- a/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php +++ b/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php @@ -32,6 +32,34 @@ class DrupalComponentTest extends TestCase { } } + /** + * 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. *