You are here

public function LibraryDiscoveryIntegrationTest::testLibrariesOverrideMalformedAsset in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::testLibrariesOverrideMalformedAsset()
  2. 10 core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\KernelTests\Core\Asset\LibraryDiscoveryIntegrationTest::testLibrariesOverrideMalformedAsset()

Tests libraries-override on malformed assets.

File

core/tests/Drupal/KernelTests/Core/Asset/LibraryDiscoveryIntegrationTest.php, line 114

Class

LibraryDiscoveryIntegrationTest
Tests the library discovery and library discovery parser.

Namespace

Drupal\KernelTests\Core\Asset

Code

public function testLibrariesOverrideMalformedAsset() {

  // Activate test theme that overrides with a malformed asset.
  $this
    ->activateTheme('test_theme_libraries_override_with_invalid_asset');

  // Assert that improperly formed asset "specs" throw an exception.
  try {
    $this->libraryDiscovery
      ->getLibraryByName('core', 'drupal.dialog');
    $this
      ->fail('Throw Exception when specifying invalid override');
  } catch (InvalidLibrariesOverrideSpecificationException $e) {
    $expected_message = 'Library asset core/drupal.dialog/css is not correctly specified. It should be in the form "extension/library_name/sub_key/path/to/asset.js".';
    $this
      ->assertEqual($e
      ->getMessage(), $expected_message, 'Throw Exception when specifying invalid override');
  }
}