You are here

function LibrariesTestCase::testLibrariesLoad in Libraries API 7.3

Tests libraries_load().

File

tests/libraries.test, line 312
Tests for Libraries API.

Class

LibrariesTestCase
Tests basic detection and loading of libraries.

Code

function testLibrariesLoad() {

  // Test dependencies.
  $library = libraries_load('example_dependency_missing');
  $this
    ->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  $this
    ->assertFalse($library['loaded'], 'Library with missing dependency cannot be loaded');
  $library = libraries_load('example_dependency_incompatible');
  $this
    ->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  $this
    ->assertFalse($library['loaded'], 'Library with incompatible dependency cannot be loaded');
  $library = libraries_load('example_dependency_compatible');
  $this
    ->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  $this
    ->assertEqual($library['loaded'], 1, 'Library with compatible dependency is loaded');
  $loaded =& drupal_static('libraries_load');
  $this
    ->verbose('<pre>' . var_export($loaded, TRUE) . '</pre>');
  $this
    ->assertEqual($loaded['example_dependency']['loaded'], 1, 'Dependency library is also loaded');

  // Test that PHP files that have a local $path variable do not break library
  // loading.
  // @see _libraries_require_once()
  $library = libraries_load('example_path_variable_override');
  $this
    ->assertEqual($library['loaded'], 2, 'PHP files cannot break library loading.');
}