Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/README.txt,v retrieving revision 1.1 diff -u -p -r1.1 README.txt --- README.txt 2 Jun 2009 12:32:51 -0000 1.1 +++ README.txt 26 Jan 2011 13:15:24 -0000 @@ -23,7 +23,8 @@ Bug reports, feature suggestions and lat -- CONTACT -- Current maintainers: -* Daniel F. Kudwien (sun) - http://www.unleashedmind.com +* Daniel F. Kudwien (sun) - http://drupal.org/user/54136 +* Tobias Stöckler (tstoeckler) - http://drupal.org/user/107158 This project has been sponsored by: Index: libraries.api.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.api.php,v retrieving revision 1.5 diff -u -p -r1.5 libraries.api.php --- libraries.api.php 3 Nov 2010 22:22:42 -0000 1.5 +++ libraries.api.php 26 Jan 2011 13:15:25 -0000 @@ -25,13 +25,6 @@ * allow for multiple possible library locations. A valid use-case is an * external library, in which case the full URL to the library should be * specified here. - * - version callback: (optional) The name of a function that detects and - * 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: (optional) The version of the library. This should not be * declared normally, as it is automatically detected (see 'version * callback' below) to allow for version changes of libraries without code @@ -39,6 +32,13 @@ * library simultaneously (though only one version can be installed per * site). A valid use-case is an external library whose version cannot be * determined programatically. + * - version callback: (optional) The name of a function that detects and + * 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. * Version arguments can be declared either as an associative array whose * keys are the argument names or as an indexed array without specifying @@ -52,7 +52,7 @@ * - file: The filename to parse for the version, relative to the library * path. For example: 'docs/changelog.txt'. * - pattern: A string containing a regular expression (PCRE) to match the - * library version. For example: '/@version (\d+)\.(\d+)/'. + * library version. For example: '@version\s+([0-9a-zA-Z\.-]+)@'. * - lines: (optional) The maximum number of lines to search the pattern in. * Defaults to 20. * - cols: (optional) The maximum number of characters per line to take into @@ -72,15 +72,16 @@ * associative array of top-level properties that are entirely overridden by * the variant, most often just 'files'. Additionally, each variant can * contain following properties: - * - 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 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 callback: (optional) The name of a function that detects the + * variant and 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 second + * argument 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 @@ -89,19 +90,19 @@ * 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. + * Variants can be version-specific (see 'versions'). * - 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 + * Naturally, libraries evolve over time and so do their APIs. In case a + * library changes between versions, different 'files' may need to be * loaded, different 'variants' may become available, or Drupal modules need - * to load different integration files adapted to the new version. - * Each key is a version *string* (PHP does not support floats as keys). - * Each value is an associative array of top-level properties that are - * entirely overridden by the version. + * to load different integration files adapted to the new version. Each key + * is a version *string* (PHP does not support floats as keys). Each value + * is an associative array of top-level properties that are entirely + * overridden by the version. * - integration files: (optional) An associative array whose keys are module * names and whose values are sets of files to load for the module, using * the same notion as the top-level 'files' property. Each specified file - * should contain the full path to the file. + * should contain the path to the file relative to the module it belongs to. * Additional top-level properties can be registered as needed. * * @see hook_library() @@ -126,7 +127,7 @@ function hook_libraries_info() { // libraries_get_version() takes a named argument array: 'version arguments' => array( 'file' => 'docs/CHANGELOG.txt', - 'pattern' => '/@version (\d+)\.(\d+)/', + 'pattern' => '@version\s+([0-9a-zA-Z\.-]+)@', 'lines' => 5, 'cols' => 20, ), @@ -183,22 +184,14 @@ function hook_libraries_info() { 'versions' => array( '2' => array( 'files' => array( - 'js' => array( - 'exlib.js', - ), - 'css' => array( - 'exlib_style.css', - ), + 'js' => array('exlib.js'), + 'css' => array('exlib_style.css'), ), ), '3.0' => array( 'files' => array( - 'js' => array( - 'exlib.js', - ), - 'css' => array( - 'lib_style.css', - ), + 'js' => array('exlib.js'), + 'css' => array('lib_style.css'), ), ), '3.2' => array( @@ -218,7 +211,7 @@ function hook_libraries_info() { // keyed by module, and follow the syntax of the 'files' property. 'integration files' => array( 'mymodule' => array( - 'js' => 'ex_lib.inc', + 'js' => array('ex_lib.inc'), ), ), ); @@ -233,13 +226,11 @@ function hook_libraries_info() { 'file' => 'readme.txt', // Best practice: Document the actual version strings for later reference. // 1.x: Version 1.0 - 'pattern' => '/Version (\d+)\.(\d+)/', + 'pattern' => '/Version (\d+)/', 'lines' => 5, ), 'files' => array( - 'js' => array( - 'simple.js', - ), + 'js' => array('simple.js'), ), ); @@ -249,6 +240,9 @@ function hook_libraries_info() { 'vendor url' => 'http://tinymce.moxiecode.com', 'download url' => 'http://tinymce.moxiecode.com/download.php', 'path' => 'jscripts/tiny_mce', + // The regular expression catches two parts (the major and the minor + // version), which libraries_get_version() doesn't allow. + 'version callback' => 'tinymce_get_version', 'version arguments' => array( // It can be easier to parse the first characters of a minified file // instead of doing a multi-line pattern matching in a source file. See @@ -275,12 +269,8 @@ function hook_libraries_info() { ), 'integration files' => array( 'wysiwyg' => array( - 'js' => array( - drupal_get_path('module', 'wysiwyg') . '/editors/js/tinymce-2.js', - ), - 'css' => array( - drupal_get_path('module', 'wysiwyg') . '/editors/js/tinymce-2.css', - ), + 'js' => array('editors/js/tinymce-2.js'), + 'css' => array('editors/js/tinymce-2.css'), ), ), ), @@ -312,12 +302,8 @@ function hook_libraries_info() { ), 'integration files' => array( 'wysiwyg' => array( - 'js' => array( - drupal_get_path('module', 'wysiwyg') . '/editors/js/tinymce-3.js', - ), - 'css' => array( - drupal_get_path('module', 'wysiwyg') . '/editors/js/tinymce-3.css', - ), + 'js' => array('editors/js/tinymce-3.js'), + 'css' => array('editors/js/tinymce-3.css'), ), ), ), Index: libraries.drush.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.drush.inc,v retrieving revision 1.2 diff -u -p -r1.2 libraries.drush.inc --- libraries.drush.inc 10 Oct 2010 03:55:16 -0000 1.2 +++ libraries.drush.inc 26 Jan 2011 13:15:25 -0000 @@ -54,34 +54,31 @@ function libraries_drush_list() { else { $header = array('Name', 'Status', 'Version', 'Variants'); $rows = array(); - foreach ($libraries as $library_name => $library) { - $version = $library['version']; + foreach ($libraries as $name => $library) { + // Status and version if ($library['installed']) { $status = 'OK'; + $version = $library['version']; } else { $status = drupal_ucfirst($library['error']); $version = (empty($library['version']) ? '-' : $library['version']); } - if (empty($library['variants'])) { + // Variants + $variants = array(); + foreach ($library['variants'] as $variant_name => $variant) { + if ($variant['installed']) { + $variants[] = $variant_name; + } + } + if (empty($variants)) { $variants = '-'; } else { - $variants = array(); - foreach ($library['variants'] as $variant_name => $variant) { - if ($variant['installed']) { - $variants[] = $variant_name; - } - } - if (empty($variants)) { - $variants = '-'; - } - else { - $variants = implode(', ', $variants); - } + $variants = implode(', ', $variants); } - $rows[] = array($library_name, $status, $version, $variants); + $rows[] = array($name, $status, $version, $variants); } $table = new Console_Table(); drush_print($table->fromArray($header, $rows)); Index: libraries.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.module,v retrieving revision 1.18 diff -u -p -r1.18 libraries.module --- libraries.module 15 Jan 2011 20:22:34 -0000 1.18 +++ libraries.module 26 Jan 2011 13:15:25 -0000 @@ -7,7 +7,7 @@ */ /** - * Helper function to build paths to libraries. + * Gets the path of a library. * * @param $name * The machine name of a library to return the path for. @@ -40,7 +40,7 @@ function libraries_get_path($name, $base } /** - * Return an array of library directories. + * Returns an array of library directories. * * Returns an array of library directories from the all-sites directory * (i.e. sites/all/libraries/), the profiles directory, and site-specific @@ -215,14 +215,13 @@ function libraries_info($name = NULL) { /** * Detect libraries and library versions. * - * @todo It makes little sense to pass $libraries by reference here. We need to - * figure out whether, and if, how we want to retain the processed - * information. I.e. either use a static cache here, or make libraries_info() - * conditionally invoke libraries_detect($name). D7 only way: Re-use - * drupal_static() of libraries_info() - but would still require to update the - * (DB) cache (there likely will be one soon). - * Also, we probably do not want to ALWAYS parse ALL possible libraries; rather, - * the requesting/consuming module likely wants to know whether a list of + * @todo We need to figure out whether, and if, how we want to retain the + * processed information. I.e. either use a static cache here, or make + * libraries_info() conditionally invoke libraries_detect($name). D7 only way: + * Re-use drupal_static() of libraries_info() - but would still require to + * update the (DB) cache (there likely will be one soon). Also, we probably do + * not want to ALWAYS parse ALL possible libraries; rather, the + * requesting/consuming module likely wants to know whether a list of * supported libraries (possibly those registered by itself, or in a certain * "category") is available... Food for thought. * @@ -233,7 +232,7 @@ function libraries_info($name = NULL) { */ function libraries_detect($libraries) { foreach ($libraries as &$library) { - libraries_detect_library($library); + $library = libraries_detect_library($library); } return $libraries; } @@ -243,19 +242,18 @@ function libraries_detect($libraries) { * * @param $library * An associative array describing a single library, as returned from - * libraries_info(), passed by reference. + * libraries_info(). */ -function libraries_detect_library(&$library) { +function libraries_detect_library($library) { $library['installed'] = FALSE; - $name = $library['machine name']; // Check whether the library exists. if (!isset($library['library path'])) { - $library['library path'] = libraries_get_path($name); + $library['library path'] = libraries_get_path($library['machine name']); } if (!file_exists($library['library path'])) { $library['error'] = 'not found'; - $library['error message'] = t('%library could not be found.', array( + $library['error message'] = t('The %library library could not be found.', array( '%library' => $library['name'], )); return; @@ -274,7 +272,7 @@ function libraries_detect_library(&$libr } if (empty($library['version'])) { $library['error'] = 'not detected'; - $library['error message'] = t('The version of %library could not be detected.', array( + $library['error message'] = t('The version of the %library library could not be detected.', array( '%library' => $library['name'], )); return; @@ -292,7 +290,7 @@ function libraries_detect_library(&$libr } if (!$version) { $library['error'] = 'not supported'; - $library['error message'] = t('The installed version %version of %library is not supported.', array( + $library['error message'] = t('The installed version %version of the %library library is not supported.', array( '%version' => $library['version'], '%library' => $library['name'], )); @@ -324,7 +322,7 @@ function libraries_detect_library(&$libr } if (!$variant['installed']) { $variant['error'] = 'not found'; - $variant['error message'] = t('The %variant variant of %library could not be found.', array( + $variant['error message'] = t('The %variant variant of the %library library could not be found.', array( '%variant' => $variant_name, '%library' => $library['name'], )); @@ -335,6 +333,7 @@ function libraries_detect_library(&$libr // If we end up here, the library should be usable. $library['installed'] = TRUE; + return $library; } /** @@ -361,8 +360,7 @@ function libraries_load($name, $variant $loaded = &drupal_static(__FUNCTION__, array()); if (!isset($loaded[$name])) { - $library = libraries_info($name); - libraries_detect_library($library); + $library = libraries_detect_library(libraries_info($name)); // If a variant was specified, override the top-level properties with the // variant properties. @@ -372,6 +370,7 @@ function libraries_load($name, $variant // of the library files below. $library['variants'] += array($variant => array('installed' => FALSE)); $library = array_merge($library, $library['variants'][$variant]); + unset($library['variants']); } // If the library (variant) is installed, load it. $library['loaded'] = FALSE; @@ -467,7 +466,7 @@ function libraries_load_files($library) * - file: The filename to parse for the version, relative to the library * path. For example: 'docs/changelog.txt'. * - pattern: A string containing a regular expression (PCRE) to match the - * library version. For example: '/@version (\d+)\.(\d+)/'. + * library version. For example: '@version\s+([0-9a-zA-Z\.-]+)@'. * - lines: (optional) The maximum number of lines to search the pattern in. * Defaults to 20. * - cols: (optional) The maximum number of characters per line to take into Index: tests/libraries.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries.test,v retrieving revision 1.11 diff -u -p -r1.11 libraries.test --- tests/libraries.test 10 Nov 2010 20:57:00 -0000 1.11 +++ tests/libraries.test 26 Jan 2011 13:15:26 -0000 @@ -31,31 +31,30 @@ class LibrariesTestCase extends DrupalWe */ function testLibraries() { // Test that library information is found correctly. - $library = libraries_info('example_simple'); $expected = array_merge(libraries_info('example_empty'), array( - 'machine name' => 'example_simple', - 'name' => 'Example simple', + 'machine name' => 'example_files', + 'name' => 'Example files', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('1'), + 'version' => '1', 'files' => array( 'js' => array('example_1.js'), 'css' => array('example_1.css'), 'php' => array('example_1.php'), ), )); + $library = libraries_info('example_files'); $this->verbose(var_export($expected, TRUE)); $this->verbose(var_export($library, TRUE)); $this->assertEqual($library, $expected, 'Library information is correctly gathered.'); // Test a library specified with an .info file gets detected. - $library = libraries_info('example_info_file'); $expected = array_merge(libraries_info('example_empty'), array( 'machine name' => 'example_info_file', 'name' => 'Example info file', 'info file' => drupal_get_path('module', 'libraries_test') . '/example/example_info_file.libraries.info', )); unset($expected['module']); + $library = libraries_info('example_info_file'); $this->verbose(var_export($expected, TRUE)); $this->verbose(var_export($library, TRUE)); $this->assertEqual($library, $expected, 'Library specified with an .info file found'); @@ -65,7 +64,7 @@ class LibrariesTestCase extends DrupalWe libraries_detect_library($library); $this->verbose(var_export($library, TRUE)); $this->assertEqual($library['error'], 'not found', 'Missing library not found.'); - $error_message = t('%library could not be found.', array( + $error_message = t('The %library library could not be found.', array( '%library' => $library['name'], )); $this->assertEqual($library['error message'], $error_message, 'Correct error message for a missing library.'); @@ -75,7 +74,7 @@ class LibrariesTestCase extends DrupalWe libraries_detect_library($library); $this->verbose(var_export($library, TRUE)); $this->assertEqual($library['error'], 'not detected', 'Undetected version detected as such.'); - $error_message = t('The version of %library could not be detected.', array( + $error_message = t('The version of the %library library could not be detected.', array( '%library' => $library['name'], )); $this->assertEqual($library['error message'], $error_message, 'Correct error message for a library with an undetected version.'); @@ -85,7 +84,7 @@ class LibrariesTestCase extends DrupalWe libraries_detect_library($library); $this->verbose(var_export($library, TRUE)); $this->assertEqual($library['error'], 'not supported', 'Unsupported version detected as such.'); - $error_message = t('The installed version %version of %library is not supported.', array( + $error_message = t('The installed version %version of the %library library is not supported.', array( '%version' => $library['version'], '%library' => $library['name'], )); @@ -100,19 +99,17 @@ class LibrariesTestCase extends DrupalWe // Test libraries_get_version(). $library = libraries_info('example_default_version_callback'); libraries_detect_library($library); - $version = '2'; $this->verbose(var_export($library, TRUE)); - $this->assertEqual($library['version'], $version, 'Expected version returned by default version callback.'); + $this->assertEqual($library['version'], '1', 'Expected version returned by default version callback.'); // Test a multiple-parameter version callback. $library = libraries_info('example_multiple_parameter_version_callback'); libraries_detect_library($library); - $version = '2'; $this->verbose(var_export($library, TRUE)); - $this->assertEqual($library['version'], $version, 'Expected version returned by multiple parameter version callback.'); + $this->assertEqual($library['version'], '1', 'Expected version returned by multiple parameter version callback.'); // Test a top-level files property. - $library = libraries_info('example_simple'); + $library = libraries_info('example_files'); libraries_detect_library($library); $files = array( 'js' => array('example_1.js'), @@ -139,7 +136,7 @@ class LibrariesTestCase extends DrupalWe $variants = array_keys($library['variants']); $this->verbose(var_export($library, TRUE)); $this->assertEqual($library['variants']['example_variant']['error'], 'not found', 'Missing variant not found'); - $error_message = t('The %variant variant of %library could not be found.', array( + $error_message = t('The %variant variant of the %library library could not be found.', array( '%variant' => $variants[0], '%library' => $library['name'], )); @@ -152,8 +149,8 @@ class LibrariesTestCase extends DrupalWe $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->assertLibraryFiles('example_1', 'Simple library loading'); + $this->drupalGet('libraries_test/files'); + $this->assertLibraryFiles('example_1', 'File loading'); // Test loading of integration files. $this->drupalGet('libraries_test/integration_files'); Index: tests/libraries_test.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.css,v retrieving revision 1.3 diff -u -p -r1.3 libraries_test.css --- tests/libraries_test.css 3 Nov 2010 22:22:42 -0000 1.3 +++ tests/libraries_test.css 26 Jan 2011 13:15:26 -0000 @@ -4,7 +4,8 @@ * @file * Test CSS file for Libraries loading. * - * Color the 'libraries-test-css' div blue. See README.txt for more information. + * Color the 'libraries-test-css' div purple. See README.txt for more + * information. */ .libraries-test-css { Index: tests/libraries_test.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.info,v retrieving revision 1.1 diff -u -p -r1.1 libraries_test.info --- tests/libraries_test.info 16 Jul 2010 10:53:04 -0000 1.1 +++ tests/libraries_test.info 26 Jan 2011 13:15:26 -0000 @@ -3,5 +3,4 @@ name = Libraries test module description = Tests library detection and loading. core = 7.x dependencies[] = libraries -files[] = libraries_test.module hidden = TRUE Index: tests/libraries_test.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.js,v retrieving revision 1.4 diff -u -p -r1.4 libraries_test.js --- tests/libraries_test.js 3 Nov 2010 22:22:42 -0000 1.4 +++ tests/libraries_test.js 26 Jan 2011 13:15:26 -0000 @@ -12,7 +12,7 @@ Drupal.behaviors.librariesTest = { attach: function(context, settings) { - $('.libraries-test-javascript').text('If this text shows up, libraries_test.js was loaded successfully') + $('.libraries-test-javascript').text('If this text shows up, libraries_test.js was loaded successfully.') } }; Index: tests/libraries_test.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.module,v retrieving revision 1.7 diff -u -p -r1.7 libraries_test.module --- tests/libraries_test.module 3 Nov 2010 22:22:42 -0000 1.7 +++ tests/libraries_test.module 26 Jan 2011 13:15:26 -0000 @@ -14,8 +14,6 @@ function libraries_test_libraries_info() $libraries['example_missing'] = array( 'name' => 'Example missing', 'library path' => drupal_get_path('module', 'libraries') . '/tests/missing', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('1'), ); $libraries['example_undetected_version'] = array( 'name' => 'Example undetected version', @@ -37,9 +35,9 @@ function libraries_test_libraries_info() 'name' => 'Example supported version', 'library path' => drupal_get_path('module', 'libraries') . '/tests', 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('2'), + 'version arguments' => array('1'), 'versions' => array( - '2' => array(), + '1' => array(), ), ); @@ -49,7 +47,7 @@ function libraries_test_libraries_info() 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', 'version arguments' => array( 'file' => 'README.txt', - // Version 2 + // Version 1 'pattern' => '/Version (\d+)/', 'lines' => 5, ), @@ -57,29 +55,22 @@ function libraries_test_libraries_info() // Test a multiple-parameter version callback. $libraries['example_multiple_parameter_version_callback'] = array( - 'name' => 'Example_multiple_parameter_version_callback', + 'name' => 'Example multiple parameter version callback', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - // Version 2 + // Version 1 'version callback' => '_libraries_test_get_version', 'version arguments' => array('README.txt', '/Version (\d+)/', 5), ); // Test a top-level files property. - $libraries['example_simple'] = array( - 'name' => 'Example simple', + $libraries['example_files'] = array( + 'name' => 'Example files', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('1'), + 'version' => '1', 'files' => array( - 'js' => array( - 'example_1.js', - ), - 'css' => array( - 'example_1.css', - ), - 'php' => array( - 'example_1.php' - ), + 'js' => array('example_1.js'), + 'css' => array('example_1.css'), + 'php' => array('example_1.php'), ), ); @@ -89,8 +80,7 @@ function libraries_test_libraries_info() $libraries['example_integration_files'] = array( 'name' => 'Example integration files', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('2'), + 'version' => '1', 'integration files' => array( 'libraries_test' => array( 'js' => array('libraries_test.js'), @@ -104,8 +94,7 @@ function libraries_test_libraries_info() $libraries['example_versions'] = array( 'name' => 'Example versions', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('2'), + 'version' => '2', 'versions' => array( '1' => array( 'files' => array( @@ -128,8 +117,7 @@ function libraries_test_libraries_info() $libraries['example_variant_missing'] = array( 'name' => 'Example variant missing', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('2'), + 'version' => '1', 'variants' => array( 'example_variant' => array( 'files' => array( @@ -146,8 +134,7 @@ function libraries_test_libraries_info() $libraries['example_variant'] = array( 'name' => 'Example variant', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('2'), + 'version' => '1', 'variants' => array( 'example_variant' => array( 'files' => array( @@ -165,8 +152,7 @@ function libraries_test_libraries_info() $libraries['example_versions_and_variants'] = array( 'name' => 'Example versions and variants', 'library path' => drupal_get_path('module', 'libraries') . '/tests/example', - 'version callback' => '_libraries_test_return_version', - 'version arguments' => array('2'), + 'version' => '2', 'versions' => array( '1' => array( 'variants' => array( @@ -247,9 +233,9 @@ function _libraries_test_return_version( * 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 + * function ensures that the arguments are passed correctly. This function might + * be a useful reference for a custom version callback that uses multiple + * parameters. * * @param $library * An associative array containing all information about the library. @@ -304,10 +290,10 @@ function _libraries_test_return_installe * Implements hook_menu(). */ function libraries_test_menu() { - $items['libraries_test/simple'] = array( - 'title' => 'Test simple library', + $items['libraries_test/files'] = array( + 'title' => 'Test files', 'page callback' => '_libraries_test_load', - 'page arguments' => array('example_simple'), + 'page arguments' => array('example_files'), 'access callback' => TRUE, ); $items['libraries_test/integration_files'] = array( Index: tests/example/README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/README.txt,v retrieving revision 1.1 diff -u -p -r1.1 README.txt --- tests/example/README.txt 22 Sep 2010 17:32:46 -0000 1.1 +++ tests/example/README.txt 26 Jan 2011 13:15:26 -0000 @@ -2,7 +2,7 @@ Example library -Version 2 +Version 1 This file is an example file to test version detection. @@ -11,33 +11,33 @@ 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). + though, is not yet possible with SimpleTest. To allow for easier debugging, we + place the following text on the page: + "If this text shows up, no JavaScript test file was loaded." + This text is replaced via JavaScript by a text of the form: + "If this text shows up, [[file] was loaded successfully." + [file] is either 'example_1.js', 'example_2.js', 'example_3.js', + 'example_4.js' or 'libraries_test.js'. If you have SimpleTest's verbose mode + enabled and see the above text in one of the debug pages, the noted JavaScript + file was loaded successfully. - 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: + possible with SimpleTest. Hence, the CSS files, if loaded, make the following + text a certain color: + "If one of the CSS test files has been loaded, this text will be colored: - 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. + - libraries_test: purple" + If you have SimpleTest's verbose mode enabled, 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 as referenced in the text above. - 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. +not in the same directory as this file). Index: tests/example/example_1.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_1.js,v retrieving revision 1.2 diff -u -p -r1.2 example_1.js --- tests/example/example_1.js 3 Nov 2010 22:22:42 -0000 1.2 +++ tests/example/example_1.js 26 Jan 2011 13:15:26 -0000 @@ -12,7 +12,7 @@ Drupal.behaviors.librariesTest = { attach: function(context, settings) { - $('.libraries-test-javascript').text('If this text shows up, example_1.js was loaded successfully') + $('.libraries-test-javascript').text('If this text shows up, example_1.js was loaded successfully.') } }; Index: tests/example/example_2.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_2.js,v retrieving revision 1.2 diff -u -p -r1.2 example_2.js --- tests/example/example_2.js 3 Nov 2010 22:22:42 -0000 1.2 +++ tests/example/example_2.js 26 Jan 2011 13:15:26 -0000 @@ -12,7 +12,7 @@ Drupal.behaviors.librariesTest = { attach: function(context, settings) { - $('.libraries-test-javascript').text('If this text shows up, example_2.js was loaded successfully') + $('.libraries-test-javascript').text('If this text shows up, example_2.js was loaded successfully.') } }; Index: tests/example/example_3.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_3.js,v retrieving revision 1.2 diff -u -p -r1.2 example_3.js --- tests/example/example_3.js 3 Nov 2010 22:22:42 -0000 1.2 +++ tests/example/example_3.js 26 Jan 2011 13:15:26 -0000 @@ -12,7 +12,7 @@ Drupal.behaviors.librariesTest = { attach: function(context, settings) { - $('.libraries-test-javascript').text('If this text shows up, example_3.js was loaded successfully') + $('.libraries-test-javascript').text('If this text shows up, example_3.js was loaded successfully.') } }; Index: tests/example/example_4.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/example/example_4.js,v retrieving revision 1.2 diff -u -p -r1.2 example_4.js --- tests/example/example_4.js 3 Nov 2010 22:22:42 -0000 1.2 +++ tests/example/example_4.js 26 Jan 2011 13:15:26 -0000 @@ -12,7 +12,7 @@ Drupal.behaviors.librariesTest = { attach: function(context, settings) { - $('.libraries-test-javascript').text('If this text shows up, example_4.js was loaded successfully') + $('.libraries-test-javascript').text('If this text shows up, example_4.js was loaded successfully.') } };