Further modules included.
[yaffs-website] / web / modules / contrib / libraries / tests / src / Kernel / ExternalLibrary / GlobalLocatorTest.php
1 <?php
2
3 namespace Drupal\Tests\libraries\Kernel\ExternalLibrary;
4
5 use Drupal\Tests\libraries\Kernel\ExternalLibrary\TestLibraryFilesStream;
6 use Drupal\Tests\libraries\Kernel\LibraryTypeKernelTestBase;
7
8 /**
9  * Tests that a global locator can be properly used to load a libraries.
10  *
11  * @group libraries
12  */
13 class GlobalLocatorTest extends LibraryTypeKernelTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setUp() {
19     parent::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'),
26       'libraries'
27     ));
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   protected function getLibraryTypeId() {
34     return 'php_file';
35   }
36
37   /**
38    * Tests that the library is located via the global loactor.
39    */
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://']]])
48       ->save();
49     $library = $this->getLibrary();
50     $this->assertTrue($library->isInstalled());
51   }
52
53 }