You are here

public function LibrariesLoadWebTest::testLibrariesLoad in Libraries API 7.2

Tests libraries_load().

File

tests/LibrariesLoadWebTest.test, line 283
Contains LibrariesLoadWebTest.

Class

LibrariesLoadWebTest
Tests basic detection and loading of libraries.

Code

public 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.');
}