You are here

public function LibraryDiscoveryParserTest::testVersion in Drupal 8

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

Tests the version property, and how it propagates to the contained assets.

@covers ::buildByExtension

File

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

Class

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

Namespace

Drupal\Tests\Core\Asset

Code

public function testVersion() {
  $this->moduleHandler
    ->expects($this
    ->atLeastOnce())
    ->method('moduleExists')
    ->with('versions')
    ->will($this
    ->returnValue(TRUE));
  $path = __DIR__ . '/library_test_files';
  $path = substr($path, strlen($this->root) + 1);
  $this->libraryDiscoveryParser
    ->setPaths('module', 'versions', $path);
  $libraries = $this->libraryDiscoveryParser
    ->buildByExtension('versions');
  $this
    ->assertArrayNotHasKey('version', $libraries['versionless']);
  $this
    ->assertEquals(-1, $libraries['versionless']['css'][0]['version']);
  $this
    ->assertEquals(-1, $libraries['versionless']['js'][0]['version']);
  $this
    ->assertEquals('9.8.7.6', $libraries['versioned']['version']);
  $this
    ->assertEquals('9.8.7.6', $libraries['versioned']['css'][0]['version']);
  $this
    ->assertEquals('9.8.7.6', $libraries['versioned']['js'][0]['version']);
  $this
    ->assertEquals(\Drupal::VERSION, $libraries['core-versioned']['version']);
  $this
    ->assertEquals(\Drupal::VERSION, $libraries['core-versioned']['css'][0]['version']);
  $this
    ->assertEquals(\Drupal::VERSION, $libraries['core-versioned']['js'][0]['version']);
}