You are here

function _libraries_test_module_load in Libraries API 7.2

Same name and namespace in other branches
  1. 7.3 tests/modules/libraries_test_module/libraries_test_module.module \_libraries_test_module_load()

Loads a specified library (variant) for testing.

JavaScript and CSS files can be checked directly by SimpleTest, so we only need to manually check for PHP files. We provide information about the loaded JavaScript and CSS files for easier debugging. See example/README.txt for more information.

1 string reference to '_libraries_test_module_load'
libraries_test_module_menu in tests/modules/libraries_test_module/libraries_test_module.module
Implements hook_menu().

File

tests/modules/libraries_test_module/libraries_test_module.module, line 578
Tests the library detection and loading.

Code

function _libraries_test_module_load($library, $variant = NULL) {
  libraries_load($library, $variant);

  // JavaScript and CSS files can be checked directly by SimpleTest, so we only
  // need to manually check for PHP files.
  $output = '';

  // For easer debugging of JS loading, a text is shown that the JavaScript will
  // replace.
  $output .= '<h2>JavaScript</h2>';
  $output .= '<div class="libraries-test-module-js">';
  $output .= 'If this text shows up, no JavaScript test file was loaded.';
  $output .= '</div>';

  // For easier debugging of CSS loading, the loaded CSS files will color the
  // following text.
  $output .= '<h2>CSS</h2>';
  $output .= '<div class="libraries-test-module-css">';
  $output .= 'If one of the CSS test files has been loaded, this text will be colored:';
  $output .= '<ul>';

  // Do not reference the actual CSS files (i.e. including '.css'), because that
  // breaks testing.
  $output .= '<li>example_1: red</li>';
  $output .= '<li>example_2: green</li>';
  $output .= '<li>example_3: orange</li>';
  $output .= '<li>example_4: blue</li>';
  $output .= '<li>libraries_test_module: purple</li>';
  $output .= '<li>libraries_test_theme: turquoise</li>';
  $output .= '</ul>';
  $output .= '</div>';
  $output .= '<h2>PHP</h2>';
  $output .= '<div class="libraries-test-module-php">';
  $output .= 'The following is a list of all loaded test PHP files:';
  $output .= '<ul>';
  $files = get_included_files();
  foreach ($files as $file) {
    if (strpos($file, 'libraries/test') && !strpos($file, 'libraries_test_module.module') && !strpos($file, 'template.php')) {
      $output .= '<li>' . str_replace(DRUPAL_ROOT . '/', '', $file) . '</li>';
    }
  }
  $output .= '</ul>';
  $output .= '</div>';
  return $output;
}