X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Flibraries%2Ftests%2Fsrc%2FKernel%2FExternalLibrary%2FPhpFile%2FPhpFileLibraryTest.php;fp=web%2Fmodules%2Fcontrib%2Flibraries%2Ftests%2Fsrc%2FKernel%2FExternalLibrary%2FPhpFile%2FPhpFileLibraryTest.php;h=10c1d2cfee45cc789d1632925badba861e15391a;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/libraries/tests/src/Kernel/ExternalLibrary/PhpFile/PhpFileLibraryTest.php b/web/modules/contrib/libraries/tests/src/Kernel/ExternalLibrary/PhpFile/PhpFileLibraryTest.php new file mode 100644 index 000000000..10c1d2cfe --- /dev/null +++ b/web/modules/contrib/libraries/tests/src/Kernel/ExternalLibrary/PhpFile/PhpFileLibraryTest.php @@ -0,0 +1,66 @@ +container->set('stream_wrapper.php_file_libraries', new TestLibraryFilesStream( + $this->container->get('module_handler'), + $this->container->get('string_translation'), + 'libraries' + )); + } + + /** + * {@inheritdoc} + */ + protected function getLibraryTypeId() { + return 'php_file'; + } + + /** + * Tests that the list of PHP files is correctly gathered. + */ + public function testPhpFileInfo() { + /** @var \Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLibrary $library */ + $library = $this->getLibrary(); + $this->assertTrue($library->isInstalled()); + $library_path = $this->modulePath . '/tests/libraries/test_php_file_library'; + $this->assertEquals($library_path, $library->getLocalPath()); + $this->assertEquals(["$library_path/test_php_file_library.php"], $library->getPhpFiles()); + } + + /** + * Tests that the external library manager properly loads PHP files. + * + * @see \Drupal\libraries\ExternalLibrary\ExternalLibraryManager + * @see \Drupal\libraries\ExternalLibrary\ExternalLibraryTrait + * @see \Drupal\libraries\ExternalLibrary\PhpFile\PhpRequireLoader + */ + public function testFileLoading() { + $function_name = '_libraries_test_php_function'; + if (function_exists($function_name)) { + $this->markTestSkipped('Cannot test file inclusion if the file to be included has already been included prior.'); + return; + } + + $this->assertFalse(function_exists($function_name)); + $this->libraryManager->load('test_php_file_library'); + $this->assertTrue(function_exists($function_name)); + } + +}