3 namespace Drupal\Tests\libraries\Kernel\ExternalLibrary;
5 use Drupal\Tests\libraries\Kernel\ExternalLibrary\TestLibraryFilesStream;
6 use Drupal\Tests\libraries\Kernel\LibraryTypeKernelTestBase;
9 * Tests that a global locator can be properly used to load a libraries.
13 class GlobalLocatorTest extends LibraryTypeKernelTestBase {
18 protected function setUp() {
20 // Assign our test stream (which points to the test php lib) to the asset
21 // scheme. This gives us a scheme to work with in the test that is not
22 // used to locate a php lib by default.
23 $this->container->set('stream_wrapper.asset_libraries', new TestLibraryFilesStream(
24 $this->container->get('module_handler'),
25 $this->container->get('string_translation'),
33 protected function getLibraryTypeId() {
38 * Tests that the library is located via the global loactor.
40 public function testGlobalLocator() {
41 // By default the library will not be locatable (control assertion) until we
42 // add the asset stream to the global loctors conf list.
43 $library = $this->getLibrary();
44 $this->assertFalse($library->isInstalled());
45 $config_factory = $this->container->get('config.factory');
46 $config_factory->getEditable('libraries.settings')
47 ->set('global_locators', [['id' => 'uri', 'configuration' => ['uri' => 'asset://']]])
49 $library = $this->getLibrary();
50 $this->assertTrue($library->isInstalled());