You are here

public function LibraryDiscoveryIntegrationTest::testLibrariesOverrideDrupalSettings in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php \Drupal\system\Tests\Asset\LibraryDiscoveryIntegrationTest::testLibrariesOverrideDrupalSettings()

Tests libraries-override on drupalSettings.

File

core/modules/system/src/Tests/Asset/LibraryDiscoveryIntegrationTest.php, line 101
Contains \Drupal\system\Tests\Asset\LibraryDiscoveryIntegrationTest.

Class

LibraryDiscoveryIntegrationTest
Tests the library discovery and library discovery parser.

Namespace

Drupal\system\Tests\Asset

Code

public function testLibrariesOverrideDrupalSettings() {

  // Activate test theme that attempts to override drupalSettings.
  $this
    ->activateTheme('test_theme_libraries_override_with_drupal_settings');

  // Assert that drupalSettings cannot be overridden and throws an exception.
  try {
    $this->libraryDiscovery
      ->getLibraryByName('core', 'drupal.ajax');
    $this
      ->fail('Throw Exception when trying to override drupalSettings');
  } catch (InvalidLibrariesOverrideSpecificationException $e) {
    $expected_message = 'drupalSettings may not be overridden in libraries-override. Trying to override core/drupal.ajax/drupalSettings. Use hook_library_info_alter() instead.';
    $this
      ->assertEqual($e
      ->getMessage(), $expected_message, 'Throw Exception when trying to override drupalSettings');
  }
}