X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FComponent%2FDrupalComponentTest.php;h=6b08cd94eb49eabdce57c54e8043a64e835a58d2;hb=74df008bdbb3a11eeea356744f39b802369bda3c;hp=7e746d7379a6e97983953b366799c595d3aee9ac;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php index 7e746d737..6b08cd94e 100644 --- a/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php +++ b/web/core/tests/Drupal/Tests/Component/DrupalComponentTest.php @@ -2,15 +2,15 @@ namespace Drupal\Tests\Component; -use Drupal\Tests\UnitTestCase; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * General tests for \Drupal\Component that can't go anywhere else. * * @group Component */ -class DrupalComponentTest extends UnitTestCase { +class DrupalComponentTest extends TestCase { /** * Tests that classes in Component do not use any Core class. @@ -32,6 +32,34 @@ class DrupalComponentTest extends UnitTestCase { } } + /** + * 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. * @@ -64,7 +92,7 @@ class DrupalComponentTest extends UnitTestCase { protected function assertNoCoreUsage($class_path) { $contents = file_get_contents($class_path); preg_match_all('/^.*Drupal\\\Core.*$/m', $contents, $matches); - $matches = array_filter($matches[0], function($line) { + $matches = array_filter($matches[0], function ($line) { // Filter references to @see as they don't really matter. return strpos($line, '@see') === FALSE; });