Index: libraries.api.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.api.php,v
retrieving revision 1.2
diff -u -p -r1.2 libraries.api.php
--- libraries.api.php	23 Jul 2010 12:57:01 -0000	1.2
+++ libraries.api.php	28 Aug 2010 17:12:18 -0000
@@ -21,17 +21,21 @@
  *     actual library. Only required if the extracted download package contains
  *     the actual library files in a sub-directory.
  *   - version callback: (optional) The name of a function that detects and
- *     returns the full version string of the library. Defaults to
- *     libraries_get_version(). The first argument is always $library, an array
- *     containing all library information as described here. The following
- *     argument(s) can either be:
- *     - options: An associative array of additional information to pass to the
- *       version callback. In this case the version arguments (see below) must
- *       be declared as an associative array.
- *     - or any number of independent arguments. In this case the version
- *       arguments (see below) must be declared as an indexed array.
+ *     returns the full version string of the library. The first argument is
+ *     always $library, an array containing all library information as described
+ *     here. There are two ways to declare the version callback's additional
+ *     arguments, either as a single $options parameter or as multiple
+ *     parameters, which correspond to the two ways to specify the argument
+ *     values (see 'version arguments'). Defaults to libraries_get_version().
  *   - version arguments: A list of arguments to pass to the version callback.
- *     The default version callback libraries_get_version() expects a single,
+ *     Version arguments can be declared either as an associative array whose
+ *     keys are the argument names or as an indexed array without specifying
+ *     keys. If declared as an associative array, the arguments get passed to
+ *     the version callback as a single $options parameter whose keys are the
+ *     argument names (i.e. $options is identical to the specified array). If
+ *     declared as an indexed array, the array values get passed to the version
+ *     callback as seperate arguments in the order they were declared. The
+ *     default version callback libraries_get_version() expects a single,
  *     associative array with named keys:
  *     - file: The filename to parse for the version, relative to the library
  *       path. For example: 'docs/changelog.txt'.
@@ -59,17 +63,21 @@
  *     - variant callback: (optional) The name of a function that detects
  *       returns TRUE or FALSE, depending on whether the variant is available or
  *       not. The first argument is always $library, an array containing all
- *       library information as described here. The seconds argument is always
- *       $name, a string containing the name of the variant. The following 
- *       argument(s) can either be:
- *       - options: An associative array of additional information to pass to
- *         the version callback. In this case the version arguments (see below)
- *         must be declared as an associative array.
- *       - or any number of independent arguments. In this case the version
- *         arguments (see below) must be declared as an indexed array.
- *       If ommitted, the variant is expected to always be available. Variants
- *       can be version specific.
+ *       library information as described here. The second is always a string
+ *       containing the variant name. There are two ways to declare the variant
+ *       callback's additinal arguments, either as a single $options parameter
+ *       or as multiple parameters, which correspond to the two ways to specify
+ *       the argument values (see 'variant arguments'). If ommitted, the variant
+ *       is expected to always be available.
  *     - variant arguments: A list of arguments to pass to the variant callback.
+ *       Variant arguments can be declared either as an associative array whose
+ *       keys are the argument names or as an indexed array without specifying
+ *       keys. If declared as an associative array, the arguments get passed to
+ *       the variant callback as a single $options parameter whose keys are the
+ *       argument names (i.e. $options is identical to the specified array). If
+ *       declared as an indexed array, the array values get passed to the
+ *       variant callback as seperate arguments in the order they were declared.
+ *     Variants can be version specific.
  *   - versions: (optional) An associative array of supported library versions.
  *     Naturally, external libraries evolve over time and so do their APIs. In
  *     case a library changes between versions, different 'files' may need to be
Index: tests/libraries.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries.test,v
retrieving revision 1.3
diff -u -p -r1.3 libraries.test
--- tests/libraries.test	23 Jul 2010 12:57:01 -0000	1.3
+++ tests/libraries.test	28 Aug 2010 17:12:18 -0000
@@ -72,9 +72,9 @@ class LibrariesTestCase extends DrupalWe
     $library = libraries_info('example_simple');
     libraries_detect_library($library);
     $files = array(
-      'js' => array('example_installed_1.js'),
-      'css' => array('example_installed_1.css'),
-      'php' => array('example_installed_1.php'),
+      'js' => array('example_1.js'),
+      'css' => array('example_1.css'),
+      'php' => array('example_1.php'),
     );
     $this->assertEqual($library['files'], $files, 'Top-level files property works.');
 
@@ -82,9 +82,9 @@ class LibrariesTestCase extends DrupalWe
     $library = libraries_info('example_versions');
     libraries_detect_library($library);
     $files = array(
-      'js' => array('example_installed_2.js'),
-      'css' => array('example_installed_2.css'),
-      'php' => array('example_installed_2.php'),
+      'js' => array('example_2.js'),
+      'css' => array('example_2.css'),
+      'php' => array('example_2.php'),
     );
     $this->assertEqual($library['files'], $files, 'Version-specific library files found.');
 
@@ -96,18 +96,16 @@ class LibrariesTestCase extends DrupalWe
       '%variant' => $variants[0],
       '%library' => $library['title'],
     ));
-    $this->assertEqual($library['variants']['example_variant_1']['error'], $error, 'Missing variant not found.');
+    $this->assertEqual($library['variants']['example_variant']['error'], $error, 'Missing variant not found.');
 
     // Test existing variant.
     $library = libraries_info('example_variant');
     libraries_detect_library($library);
-    $this->assertEqual($library['variants']['example_variant_1']['installed'], TRUE, 'Existing variant found.');
+    $this->assertEqual($library['variants']['example_variant']['installed'], TRUE, 'Existing variant found.');
 
     // Test loading of a simple library with a top-level files property.
     $this->drupalGet('libraries_test/simple');
-    $this->assertRaw('example_installed_1.js', 'A JavaScript file is loaded correctly.');
-    $this->assertRaw('example_installed_1.css', 'A CSS file is loaded correctly.');
-    $this->assertText('example_installed_1.php', 'A PHP file is loaded correctly.');
+    $this->assertLibraryFiles('example_1');
 
     // Test loading of integration files.
     $this->drupalGet('libraries_test/integration_files');
@@ -117,37 +115,47 @@ class LibrariesTestCase extends DrupalWe
 
     // Test version overloading.
     $this->drupalGet('libraries_test/versions');
-    $this->assertNoRaw('example_installed_1.js', 'The JavaScript file of the wrong library version is not loaded.');
-    $this->assertNoRaw('example_installed_1.css', 'The CSS file of the wrong library version is not loaded.');
-    $this->assertNoText('example_installed_1.php', 'The PHP file of the wrong library version is not loaded.');
-    $this->assertRaw('example_installed_2.js', 'The JavaScript file of the correct library version is loaded.');
-    $this->assertRaw('example_installed_2.css', 'The CSS file of the correct library version is loaded.');
-    $this->assertText('example_installed_2.php', 'The PHP file of the correct library version is loaded.');
+    $this->assertLibraryFiles('example_2');
 
     // Test variant loading.
     $this->drupalGet('libraries_test/variant');
-    $this->assertNoRaw('example_installed_variant_2.js', 'The JavaScript file of the wrong library variant is not loaded.');
-    $this->assertNoRaw('example_installed_variant_2.css', 'The CSS file of the wrong library variant is not loaded.');
-    $this->assertNoText('example_installed_variant_2.php', 'The PHP file of the wrong library variant is not loaded.');
-    $this->assertRaw('example_installed_variant_1.js', 'The JavaScript file of the correct library variant is loaded.');
-    $this->assertRaw('example_installed_variant_1.css', 'The CSS file of the correct library variant is loaded.');
-    $this->assertText('example_installed_variant_1.php', 'The PHP file of the correct library variant is loaded.');
+    $this->assertLibraryFiles('example_3');
 
     // Test version overloading and variant loading.
     $this->drupalGet('libraries_test/versions_and_variants');
-    $this->assertNoRaw('example_installed_1.js', 'The JavaScript file of the wrong library version and variant is not loaded.');
-    $this->assertNoRaw('example_installed_1.css', 'The CSS file of the wrong library version and variant is not loaded.');
-    $this->assertNoText('example_installed_1.php', 'The PHP file of the wrong library version and variant is not loaded.');
-    $this->assertNoRaw('example_installed_2.js', 'The JavaScript file of the wrong library version and variant is not loaded.');
-    $this->assertNoRaw('example_installed_2.css', 'The CSS file of the wrong library version and variant is not loaded.');
-    $this->assertNoText('example_installed_2.php', 'The PHP file of the wrong library version and variant is not loaded.');
-    $this->assertNoRaw('example_installed_variant_1.js', 'The JavaScript file of the wrong library version and variant is not loaded.');
-    $this->assertNoRaw('example_installed_variant_1.css', 'The CSS file of the wrong library version and variant is not loaded.');
-    $this->assertNoText('example_installed_variant_1.php', 'The PHP file of the wrong library version and variant is not loaded.');
-    $this->assertRaw('example_installed_variant_2.js', 'The JavaScript file of the correct library version and variant is loaded.');
-    $this->assertRaw('example_installed_variant_2.css', 'The CSS file of the correct library version and variant is loaded.');
-    $this->assertText('example_installed_variant_2.php', 'The PHP file of the correct library version and variant is loaded.');
+    $this->assertLibraryFiles('example_4');
+  }
 
+  /**
+   * Helper function to assert that a library was correctly loaded.
+   *
+   * Asserts that all the correct files were loaded and all the incorrect ones
+   * were not.
+   *
+   * @param $name
+   *   The name of the files that should be loaded. The current testing system
+   *   knows of 'example_1', 'example_2', 'example_3' and 'example_4'. Each name
+   *   has an associated JavaScript, CSS and PHP file that will be asserted. All
+   *   other files will be asserted to not be loaded. See
+   *   tests/example/README.txt for more information on how the loading of the
+   *   files is tested.
+   */
+  private function assertLibraryFiles($name) {
+    $names = drupal_map_assoc(array('example_1', 'example_2', 'example_3', 'example_4'));
+    unset($names[$name]);
+
+    // Test that the wrong files are not loaded.
+    foreach ($names as $filename) {
+      $this->assertNoRaw("$filename.js", 'A wrong JavaScript file is not loaded.');
+      $this->assertNoRaw("$filename.css", 'A wrong CSS file is not loaded.');
+      $this->assertNoText("$filename.php", 'A wrong PHP file is not loaded.');
+    }
+
+    // Test that the correct files are loaded.
+    $this->assertRaw("$name.js", 'The correct JavaScript file is loaded.');
+    $this->assertRaw("$name.css", 'The correct CSS file is loaded.');
+    $this->assertText("$name.php", 'The correct PHP file is loaded.');
   }
+
 }
 
Index: tests/libraries_test.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.inc,v
retrieving revision 1.2
diff -u -p -r1.2 libraries_test.inc
--- tests/libraries_test.inc	23 Jul 2010 12:57:01 -0000	1.2
+++ tests/libraries_test.inc	28 Aug 2010 17:12:18 -0000
@@ -8,5 +8,5 @@
 /**
  * Dummy function to see if this file was loaded.
  */
-function libraries_test_1() {
+function _libraries_test_integration_file() {
 }
Index: tests/libraries_test.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.js,v
retrieving revision 1.2
diff -u -p -r1.2 libraries_test.js
--- tests/libraries_test.js	23 Jul 2010 12:57:01 -0000	1.2
+++ tests/libraries_test.js	28 Aug 2010 17:12:18 -0000
@@ -16,4 +16,4 @@ Drupal.behaviors.librariesTest = {
   }
 };
 
-})(jQuery); 
+})(jQuery);
Index: tests/libraries_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.module,v
retrieving revision 1.2
diff -u -p -r1.2 libraries_test.module
--- tests/libraries_test.module	23 Jul 2010 12:57:01 -0000	1.2
+++ tests/libraries_test.module	28 Aug 2010 17:12:19 -0000
@@ -8,24 +8,23 @@
 
 /**
  * Implements hook_libraries_info().
- *
- * Note: DO NOT use drupal_get_path() in your implementations! Used for testing
- * purposes only. It is strongly discouraged to declare the 'library path'
- * property as that will be detected by Libraries API automatically.
  */
 function libraries_test_libraries_info() {
   // Test library detection.
   $libraries['example_missing'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/missing',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
   );
   $libraries['example_undetected_version'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array(FALSE),
   );
   $libraries['example_unsupported_version'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
@@ -35,6 +34,7 @@ function libraries_test_libraries_info()
   );
 
   $libraries['example_supported_version'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -45,9 +45,10 @@ function libraries_test_libraries_info()
 
   // Test the default version callback.
   $libraries['example_default_version_callback'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version arguments' => array(
-      'file' => 'example_installed.txt',
+      'file' => 'README.txt',
       // Version 2
       'pattern' => '/Version (\d+)/',
       'lines' => 5,
@@ -56,26 +57,28 @@ function libraries_test_libraries_info()
 
   // Test a multiple-parameter version callback.
   $libraries['example_multiple_parameter_version_callback'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     // Version 2
-    'version callback' => '_libraries_get_version',
-    'version arguments' => array('example_installed.txt', '/Version (\d+)/', 5),
+    'version callback' => '_libraries_test_get_version',
+    'version arguments' => array('README.txt', '/Version (\d+)/', 5),
   );
 
   // Test a top-level files property.
   $libraries['example_simple'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
     'files' => array(
       'js' => array(
-        'example_installed_1.js',
+        'example_1.js',
       ),
       'css' => array(
-        'example_installed_1.css',
+        'example_1.css',
       ),
       'php' => array(
-        'example_installed_1.php'
+        'example_1.php'
       ),
     ),
   );
@@ -84,6 +87,7 @@ function libraries_test_libraries_info()
   // Normally added by the corresponding module via hook_libraries_info_alter(),
   // these files should be automatically loaded when the library is loaded.
   $libraries['example_integration_files'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -104,6 +108,7 @@ function libraries_test_libraries_info()
 
   // Test version overloading.
   $libraries['example_versions'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -111,26 +116,26 @@ function libraries_test_libraries_info()
       '1' => array(
         'files' => array(
           'js' => array(
-            'example_installed_1.js',
+            'example_1.js',
           ),
           'css' => array(
-            'example_installed_1.css',
+            'example_1.css',
           ),
           'php' => array(
-            'example_installed_1.php',
+            'example_1.php',
           ),
         ),
       ),
       '2' => array(
         'files' => array(
           'js' => array(
-            'example_installed_2.js',
+            'example_2.js',
           ),
           'css' => array(
-            'example_installed_2.css',
+            'example_2.css',
           ),
           'php' => array(
-            'example_installed_2.php',
+            'example_2.php',
           ),
         ),
       ),
@@ -139,61 +144,63 @@ function libraries_test_libraries_info()
 
   // Test variant detection.
   $libraries['example_variant_missing'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
     'variants' => array(
-      'example_variant_1' => array(
+      'example_variant' => array(
         'files' => array(
           'js' => array(
-            'example_installed_variant_1.js',
+            'example_3.js',
           ),
           'css' => array(
-            'example_installed_variant_1.css',
+            'example_3.css',
           ),
           'php' => array(
-            'example_installed_variant_1.php',
+            'example_3.php',
           ),
         ),
-        'variant callback' => '_libraries_test_detect_variant',
+        'variant callback' => '_libraries_test_return_installed',
         'variant arguments' => array(FALSE),
       ),
     ),
   );
 
   $libraries['example_variant'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
     'variants' => array(
-      'example_variant_1' => array(
+      'example_variant' => array(
         'files' => array(
           'js' => array(
-            'example_installed_variant_1.js',
+            'example_3.js',
           ),
           'css' => array(
-            'example_installed_variant_1.css',
+            'example_3.css',
           ),
           'php' => array(
-            'example_installed_variant_1.php',
+            'example_3.php',
           ),
         ),
-        'variant callback' => '_libraries_test_detect_variant',
+        'variant callback' => '_libraries_test_return_installed',
         'variant arguments' => array(TRUE),
       ),
       'example_variant_2' => array(
         'files' => array(
           'js' => array(
-            'example_installed_variant_2.js',
+            'example_4.js',
           ),
           'css' => array(
-            'example_installed_variant_2.css',
+            'example_4.css',
           ),
           'php' => array(
-            'example_installed_variant_2.php',
+            'example_4.php',
           ),
         ),
-        'variant callback' => '_libraries_test_detect_variant',
+        'variant callback' => '_libraries_test_return_installed',
         'variant arguments' => array(TRUE),
       ),
     ),
@@ -201,6 +208,7 @@ function libraries_test_libraries_info()
 
   // Test correct behaviour with multiple versions and multiple variants.
   $libraries['example_versions_and_variants'] = array(
+    // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('2'),
@@ -210,31 +218,31 @@ function libraries_test_libraries_info()
           'example_variant_1' => array(
             'files' => array(
               'js' => array(
-                'example_installed_1.js',
+                'example_1.js',
               ),
               'css' => array(
-                'example_installed_1.css',
+                'example_1.css',
               ),
               'php' => array(
-                'example_installed_1.php',
+                'example_1.php',
               ),
             ),
-            'variant callback' => '_libraries_test_detect_variant',
+            'variant callback' => '_libraries_test_return_installed',
             'variant arguments' => array(TRUE),
           ),
           'example_variant_2' => array(
             'files' => array(
               'js' => array(
-                'example_installed_variant_1.js',
+                'example_2.js',
               ),
               'css' => array(
-                'example_installed_variant_1.css',
+                'example_2.css',
               ),
               'php' => array(
-                'example_installed_variant_1.php',
+                'example_2.php',
               ),
             ),
-            'variant callback' => '_libraries_test_detect_variant',
+            'variant callback' => '_libraries_test_return_installed',
             'variant arguments' => array(TRUE),
           ),
         ),
@@ -244,31 +252,31 @@ function libraries_test_libraries_info()
           'example_variant_1' => array(
             'files' => array(
               'js' => array(
-                'example_installed_2.js',
+                'example_3.js',
               ),
               'css' => array(
-                'example_installed_2.css',
+                'example_3.css',
               ),
               'php' => array(
-                'example_installed_2.php',
+                'example_3.php',
               ),
             ),
-            'variant callback' => '_libraries_test_detect_variant',
+            'variant callback' => '_libraries_test_return_installed',
             'variant arguments' => array(TRUE),
           ),
           'example_variant_2' => array(
             'files' => array(
               'js' => array(
-                'example_installed_variant_2.js',
+                'example_4.js',
               ),
               'css' => array(
-                'example_installed_variant_2.css',
+                'example_4.css',
               ),
               'php' => array(
-                'example_installed_variant_2.php',
+                'example_4.php',
               ),
             ),
-            'variant callback' => '_libraries_test_detect_variant',
+            'variant callback' => '_libraries_test_return_installed',
             'variant arguments' => array(TRUE),
           ),
         ),
@@ -282,8 +290,9 @@ function libraries_test_libraries_info()
 /**
  * Gets the version of an example library.
  *
- * Returns exactly the version string entered as the $version parameter, unless
- * you specify 'undetected', in which case it returns nothing.
+ * Returns exactly the version string entered as the $version parameter. This
+ * function cannot be collapsed with _libraries_test_return_installed(), because
+ * of the different arguments that are passed automatically.
  */
 function _libraries_test_return_version($library, $version) {
   return $version;
@@ -292,9 +301,11 @@ function _libraries_test_return_version(
 /**
  * Gets the version information from an arbitrary library.
  *
- * This is an exact copy of libraries_get_version() except for the fact that it
- * does not take a single associative array as a parameter but multiple
- * parameters. Since we support both type of version callbacks this might be
+ * Test function for a version callback with multiple arguments. This is an
+ * exact copy of libraries_get_version(), which uses a single $option argument,
+ * except for the fact that it uses multiple arguments. Since we support both
+ * type of version callbacks, detecting the version of a test library with this
+ * ensures that the arguments are passed correctly. This function might be
  * a useful reference for a custom version callback that uses multiple
  * parameters
  *
@@ -319,7 +330,7 @@ function _libraries_test_return_version(
  *
  * @see libraries_get_version()
  */
-function _libraries_get_version($library, $file, $pattern, $lines = 20, $cols = 200) {
+function _libraries_test_get_version($library, $file, $pattern, $lines = 20, $cols = 200) {
 
   $file = DRUPAL_ROOT . '/' . $library['library path'] . '/' . $file;
   if (!file_exists($file)) {
@@ -339,11 +350,12 @@ function _libraries_get_version($library
 /**
  * Detects the variant of an example library.
  *
- * Returns TRUE or FALSE depending on whether the $status parameter is 'missing'
- * or 'found'.
+ * Returns exactly the value of $installed, either TRUE or FALSE. This function
+ * cannot be collapsed with _libraries_test_return_version(), because of the
+ * different arguments that are passed automatically.
  */
-function _libraries_test_detect_variant($library, $name, $status) {
-  return $status;
+function _libraries_test_return_installed($library, $name, $installed) {
+  return $installed;
 }
 
 /**
@@ -371,7 +383,7 @@ function libraries_test_menu() {
   $items['libraries_test/variant'] = array(
     'title' => 'Test variant loading',
     'page callback' => '_libraries_test_load',
-    'page arguments' => array('example_variant', 'example_variant_1'),
+    'page arguments' => array('example_variant', 'example_variant'),
     'access callback' => TRUE,
   );
   $items['libraries_test/versions_and_variants'] = array(
@@ -391,19 +403,19 @@ function _libraries_test_load($library, 
   // JavaScript and CSS files can be checked directly by SimpleTest, so we only
   // need to manually check for PHP files.
   $output = '';
-  if (function_exists('_libraries_example_installed_1')) {
-    $output .= 'example_installed_1.php';
+  if (function_exists('_libraries_test_example_1')) {
+    $output .= 'example_1.php';
   }
-  if (function_exists('_libraries_example_installed_2')) {
-    $output .= 'example_installed_2.php';
+  if (function_exists('_libraries_test_example_2')) {
+    $output .= 'example_2.php';
   }
-  if (function_exists('_libraries_example_installed_variant_1')) {
-    $output .= 'example_installed_variant_1.php';
+  if (function_exists('_libraries_test_example_3')) {
+    $output .= 'example_3.php';
   }
-  if (function_exists('_libraries_example_installed_variant_2')) {
-    $output .= 'example_installed_variant_2.php';
+  if (function_exists('_libraries_test_example_4')) {
+    $output .= 'example_4.php';
   }
-  if (function_exists('libraries_test_1')) {
+  if (function_exists('_libraries_test_integration_file')) {
     $output .= 'libraries_test.inc';
   }
   return $output;
Index: tests/example/README.txt
===================================================================
RCS file: tests/example/README.txt
diff -N tests/example/README.txt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/README.txt	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,43 @@
+; $Id: example_installed.txt,v 1.2 2010/07/23 12:57:01 tstoeckler Exp $
+
+Example library
+
+Version 2
+
+This file is an example file to test version detection.
+
+The various other files in this directory are to test the loading of JavaScript,
+CSS and PHP files.
+- JavaScript: The filenames of the JavaScript files are asserted to be in the
+  raw HTML via SimpleTest. Since the filename could appear, for instance, in an
+  error message, this is not very robust. Explicit testing of JavaScript,
+  though, is not yet possible with SimpleTest. Hence, the JavaScript files, if
+  loaded, insert a div with the id 'libraries-test' after the page title and put
+  some sample text in it of the form: "If this text shows up, the JavaScript
+  file was loaded successfully. If this text is [color], the CSS file was loaded
+  successfully." [color] is either 'red', 'green', 'orange' or 'blue' (see
+  below). If you enable SimpleTest's verbose mode and see the above text in one
+  of the debug pages, a JavaScript file was loaded successfully. Which file
+  depends on the color that is mentioned in the shown text (see below).
+- CSS: The filenames of the CSS files are asserted to be in the raw HTML via
+  SimpleTest. Since the filename could appear, for instance, in an error
+  message, this is not very robust. Explicit testing of CSS, though, is not yet
+  possible with SimpleTest. Hence, the CSS files, if loaded, make the text that
+  was inserted via JavaScipt (see above) a certain color. If you enable
+  SimpleTest's verbose mode, and see the above text in a certain color (i.e. not
+  in black), a CSS file was loaded successfully. Which file depends on the
+  color:
+  - example_1: red
+  - example_2: green
+  - example_3: orange
+  - example_4: blue
+  Note that, because the CSS affects a div that is inserted via JavaScript, the
+  testing of CSS loading with this method is dependent on JavaScript loading.
+- PHP: The loading of PHP files is tested by defining a dummy function in the
+  PHP files and then checking whether this function was defined using
+  function_exists(). This can be checked programatically with SimpleTest.
+The loading of integration files is tested with the same method. The integration
+files are libraries_test.js, libraries_test.css, libraries_test.inc and are
+located in the tests directory alongside libraries_test.module (i.e. they are
+not in the same directory as this file). The color that the JavaScript and CSS
+integration files refer to is purple.
Index: tests/example/example_1.css
===================================================================
RCS file: tests/example/example_1.css
diff -N tests/example/example_1.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_1.css	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+/* $Id: example_installed_1.css,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $ */
+
+/**
+ * @file
+ * Test CSS file for Libraries loading.
+ *
+ * Color the 'libraries-test' div red. See example_installed.txt for more
+ * information.
+ */
+
+div#libraries-test {
+  color: red;
+}
Index: tests/example/example_1.js
===================================================================
RCS file: tests/example/example_1.js
diff -N tests/example/example_1.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_1.js	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,19 @@
+// $Id: example_installed_1.js,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test JavaScript file for Libraries loading.
+ *
+ * Insert a 'libraries-test' div and some text below the page title. See
+ * example_installed.txt for more information.
+ */
+
+(function ($) {
+
+Drupal.behaviors.librariesTest = {
+  attach: function(context, settings) {
+    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is red, the CSS file was loaded successfully.</div>')
+  }
+};
+
+})(jQuery);
Index: tests/example/example_1.php
===================================================================
RCS file: tests/example/example_1.php
diff -N tests/example/example_1.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_1.php	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+<?php
+// $Id: example_installed_1.php,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test PHP file for Libraries loading.
+ */
+
+/**
+ * Dummy function to see if this file was loaded.
+ */
+function _libraries_test_example_1() {
+}
Index: tests/example/example_2.css
===================================================================
RCS file: tests/example/example_2.css
diff -N tests/example/example_2.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_2.css	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+/* $Id: example_installed_2.css,v 1.2 2010/07/23 12:57:01 tstoeckler Exp $ */
+
+/**
+ * @file
+ * Test CSS file for Libraries loading.
+ *
+ * Color the 'libraries-test' div green. See example_installed.txt for more
+ * information.
+ */
+
+div#libraries-test {
+  color: green;
+}
Index: tests/example/example_2.js
===================================================================
RCS file: tests/example/example_2.js
diff -N tests/example/example_2.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_2.js	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,19 @@
+// $Id: example_installed_2.js,v 1.2 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test JavaScript file for Libraries loading.
+ *
+ * Insert a 'libraries-test' div and some text below the page title. See
+ * example_installed.txt for more information.
+ */
+
+(function ($) {
+
+Drupal.behaviors.librariesTest = {
+  attach: function(context, settings) {
+    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is green, the CSS file was loaded successfully.</div>')
+  }
+};
+
+})(jQuery);
Index: tests/example/example_2.php
===================================================================
RCS file: tests/example/example_2.php
diff -N tests/example/example_2.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_2.php	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+<?php
+// $Id: example_installed_2.php,v 1.2 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test PHP file for Libraries loading.
+ */
+
+/**
+ * Dummy function to see if this file was loaded.
+ */
+function _libraries_test_example_2() {
+}
Index: tests/example/example_3.css
===================================================================
RCS file: tests/example/example_3.css
diff -N tests/example/example_3.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_3.css	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+/* $Id: example_installed_variant_1.css,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $ */
+
+/**
+ * @file
+ * Test CSS file for Libraries loading.
+ *
+ * Color the 'libraries-test' div orange. See example_installed.txt for more
+ * information.
+ */
+
+div#libraries-test {
+  color: orange;
+}
Index: tests/example/example_3.js
===================================================================
RCS file: tests/example/example_3.js
diff -N tests/example/example_3.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_3.js	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,19 @@
+// $Id: example_installed_variant_1.js,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test JavaScript file for Libraries loading.
+ *
+ * Insert a 'libraries-test' div and some text below the page title. See
+ * example_installed.txt for more information.
+ */
+
+(function ($) {
+
+Drupal.behaviors.librariesTest = {
+  attach: function(context, settings) {
+    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is orange, the CSS file was loaded successfully.</div>')
+  }
+};
+
+})(jQuery);
Index: tests/example/example_3.php
===================================================================
RCS file: tests/example/example_3.php
diff -N tests/example/example_3.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_3.php	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+<?php
+// $Id: example_installed_variant_1.php,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test PHP file for Libraries loading.
+ */
+
+/**
+ * Dummy function to see if this file was loaded.
+ */
+function _libraries_test_example_3() {
+}
Index: tests/example/example_4.css
===================================================================
RCS file: tests/example/example_4.css
diff -N tests/example/example_4.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_4.css	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+/* $Id: example_installed_variant_2.css,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $ */
+
+/**
+ * @file
+ * Test CSS file for Libraries loading.
+ *
+ * Color the 'libraries-test' div blue. See example_installed.txt for more
+ * information.
+ */
+
+div#libraries-test {
+  color: blue;
+}
Index: tests/example/example_4.js
===================================================================
RCS file: tests/example/example_4.js
diff -N tests/example/example_4.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_4.js	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,19 @@
+// $Id: example_installed_variant_2.js,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test JavaScript file for Libraries loading.
+ *
+ * Insert a 'libraries-test' div and some text below the page title. See
+ * example_installed.txt for more information.
+ */
+
+(function ($) {
+
+Drupal.behaviors.librariesTest = {
+  attach: function(context, settings) {
+    $('h1#page-title').after('<div id="libraries-test">If this text shows up, the JavaScript file was loaded successfully. If this text is blue, the CSS file was loaded successfully.</div>')
+  }
+};
+
+})(jQuery);
Index: tests/example/example_4.php
===================================================================
RCS file: tests/example/example_4.php
diff -N tests/example/example_4.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_4.php	28 Aug 2010 17:12:19 -0000
@@ -0,0 +1,13 @@
+<?php
+// $Id: example_installed_variant_2.php,v 1.1 2010/07/23 12:57:01 tstoeckler Exp $
+
+/**
+ * @file
+ * Test PHP file for Libraries loading.
+ */
+
+/**
+ * Dummy function to see if this file was loaded.
+ */
+function _libraries_test_example_4() {
+}
