function JavaScriptTest::testLibraryAlter

Adds a JavaScript library to the page and alters it.

See also

common_test_library_info_alter()

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php, line 463
Definition of Drupal\system\Tests\Common\JavaScriptTest.

Class

JavaScriptTest
Tests the JavaScript system.

Namespace

Drupal\system\Tests\Common

Code

function testLibraryAlter() {

  // Verify that common_test altered the title of Farbtastic.
  $library = drupal_get_library('system', 'jquery.farbtastic');
  $this
    ->assertEqual($library['title'], 'Farbtastic: Altered Library', 'Registered libraries were altered.');

  // common_test_library_info_alter() also added a dependency on jQuery Form.
  drupal_add_library('system', 'jquery.farbtastic');
  $scripts = drupal_get_js();
  $this
    ->assertTrue(strpos($scripts, 'core/misc/jquery.form.js'), 'Altered library dependencies are added to the page.');
}