You are here

public function MultipleAssetLibraryTest::testAssetLibraryRemote in Libraries API 8.3

Tests that a remote asset library is registered as a core asset library.

See also

\Drupal\libraries\Extension\Extension

\Drupal\libraries\Extension\ExtensionHandler

\Drupal\libraries\ExternalLibrary\Asset\AssetLibrary

\Drupal\libraries\ExternalLibrary\Asset\AssetLibraryTrait

\Drupal\libraries\ExternalLibrary\ExternalLibraryManager

\Drupal\libraries\ExternalLibrary\ExternalLibraryTrait

\Drupal\libraries\ExternalLibrary\Registry\ExternalLibraryRegistry

File

tests/src/Kernel/ExternalLibrary/Asset/MultipleAssetLibraryTest.php, line 56

Class

MultipleAssetLibraryTest
Tests that external asset libraries can register multiple core libraries.

Namespace

Drupal\Tests\libraries\Kernel\ExternalLibrary\Asset

Code

public function testAssetLibraryRemote() {
  $library = $this->coreLibraryDiscovery
    ->getLibraryByName('libraries', 'test_asset_multiple_library.first');
  $expected = [
    'version' => '1.0.0',
    'css' => [
      [
        'weight' => -200,
        'group' => 0,
        'type' => 'external',
        'data' => 'http://example.com/example.first.css',
        'version' => '1.0.0',
      ],
    ],
    'js' => [
      [
        'group' => -100,
        'type' => 'external',
        'data' => 'http://example.com/example.first.js',
        'version' => '1.0.0',
      ],
    ],
    'dependencies' => [],
    'license' => [
      'name' => 'GNU-GPL-2.0-or-later',
      'url' => 'https://www.drupal.org/licensing/faq',
      'gpl-compatible' => TRUE,
    ],
  ];
  $this
    ->assertEquals($expected, $library);
  $library = $this->coreLibraryDiscovery
    ->getLibraryByName('libraries', 'test_asset_multiple_library.second');
  $expected = [
    'version' => '1.0.0',
    'css' => [
      [
        'weight' => -200,
        'group' => 0,
        'type' => 'external',
        'data' => 'http://example.com/example.second.css',
        'version' => '1.0.0',
      ],
    ],
    'js' => [
      [
        'group' => -100,
        'type' => 'external',
        'data' => 'http://example.com/example.second.js',
        'version' => '1.0.0',
      ],
    ],
    'dependencies' => [],
    'license' => [
      'name' => 'GNU-GPL-2.0-or-later',
      'url' => 'https://www.drupal.org/licensing/faq',
      'gpl-compatible' => TRUE,
    ],
  ];
  $this
    ->assertEquals($expected, $library);
}