You are here

public function LibraryDiscoveryParserTest::testExternalLibraries in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest::testExternalLibraries()

Tests that the version property of external libraries is handled.

@covers ::buildByExtension

File

core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php, line 248
Contains \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest.

Class

LibraryDiscoveryParserTest
@coversDefaultClass \Drupal\Core\Asset\LibraryDiscoveryParser @group Asset

Namespace

Drupal\Tests\Core\Asset

Code

public function testExternalLibraries() {
  $this->moduleHandler
    ->expects($this
    ->atLeastOnce())
    ->method('moduleExists')
    ->with('external')
    ->will($this
    ->returnValue(TRUE));
  $path = __DIR__ . '/library_test_files';
  $path = substr($path, strlen($this->root) + 1);
  $this->libraryDiscoveryParser
    ->setPaths('module', 'external', $path);
  $libraries = $this->libraryDiscoveryParser
    ->buildByExtension('external');
  $library = $libraries['example_external'];
  $this
    ->assertEquals('http://example.com/css/example_external.css', $library['css'][0]['data']);
  $this
    ->assertEquals('http://example.com/example_external.js', $library['js'][0]['data']);
  $this
    ->assertEquals('3.14', $library['version']);
}