function JavaScriptTest::testGetLibrary

Tests retrieval of libraries via drupal_get_library().

File

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

Class

JavaScriptTest
Tests the JavaScript system.

Namespace

Drupal\system\Tests\Common

Code

function testGetLibrary() {

  // Retrieve all libraries registered by a module.
  $libraries = drupal_get_library('common_test');
  $this
    ->assertTrue(isset($libraries['jquery.farbtastic']), 'Retrieved all module libraries.');

  // Retrieve all libraries for a module not implementing hook_library_info().
  // Note: This test installs language module.
  $libraries = drupal_get_library('language');
  $this
    ->assertEqual($libraries, array(), 'Retrieving libraries from a module not implementing hook_library_info() returns an emtpy array.');

  // Retrieve a specific library by module and name.
  $farbtastic = drupal_get_library('common_test', 'jquery.farbtastic');
  $this
    ->assertEqual($farbtastic['version'], '5.3', 'Retrieved a single library.');

  // Retrieve a non-existing library by module and name.
  $farbtastic = drupal_get_library('common_test', 'foo');
  $this
    ->assertIdentical($farbtastic, FALSE, 'Retrieving a non-existing library returns FALSE.');
}