diff --git a/tests/libraries.test b/tests/libraries.test
index 28fb0fb..d0dee18 100644
--- a/tests/libraries.test
+++ b/tests/libraries.test
@@ -6,33 +6,33 @@
*/
/**
- * Tests basic detection and loading of libraries.
+ * Tests basic Libraries API functions.
*/
-class LibrariesTestCase extends DrupalWebTestCase {
- protected $profile = 'testing';
-
+class LibrariesUnitTestCase extends DrupalUnitTestCase {
public static function getInfo() {
return array(
- 'name' => 'Libraries detection and loading',
- 'description' => 'Tests detection and loading of libraries.',
+ 'name' => 'Libraries API unit tests',
+ 'description' => 'Tests basic functions provided by Libraries API.',
'group' => 'Libraries API',
);
}
- function setUp() {
- parent::setUp('libraries', 'libraries_test');
- }
-
/**
- * Tests libraries detection and loading.
- *
- * @todo Better method name(s); split into detection/loading/overloading/etc.
+ * Tests libraries_get_path().
*/
- function testLibraries() {
- // Test libraries_get_path().
+ public static function testLibrariesGetPath() {
+ // Note that, even though libraries_get_path() doesn't find the 'example'
+ // library, we are able to make it 'installed' by specifying the 'library
+ // path' up-front. This is only used for testing purposed and is strongly
+ // discouraged as it defeats the purpose of Libraries API in the first
+ // place.
$this->assertEqual(libraries_get_path('example'), FALSE, 'libraries_get_path() returns FALSE for a missing library.');
+ }
- // Test libraries_prepare_files().
+ /**
+ * Tests libraries_prepare_files().
+ */
+ public static function testLibrariesPrepareFiles() {
$expected = array(
'files' => array(
'js' => array('example.js' => array()),
@@ -49,8 +49,12 @@ class LibrariesTestCase extends DrupalWebTestCase {
);
libraries_prepare_files($library, NULL, NULL);
$this->assertEqual($expected, $library, 'libraries_prepare_files() works correctly.');
+ }
- // Test libraries_detect_dependencies().
+ /**
+ * Tests libraries_detect_dependencies().
+ */
+ public static function testLibrariesDetectDependencies() {
$library = array(
'name' => 'Example',
'dependencies' => array('example_missing'),
@@ -121,7 +125,33 @@ class LibrariesTestCase extends DrupalWebTestCase {
$this->verbose("Expected:
$error_message");
$this->verbose('Actual:
' . $library['error message']);
$this->assertEqual($library['error message'], $error_message, 'Correct error message for an incompatible dependency');
+ }
+}
+
+/**
+ * Tests basic detection and loading of libraries.
+ */
+class LibrariesTestCase extends DrupalWebTestCase {
+ protected $profile = 'testing';
+ public static function getInfo() {
+ return array(
+ 'name' => 'Libraries detection and loading',
+ 'description' => 'Tests detection and loading of libraries.',
+ 'group' => 'Libraries API',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('libraries', 'libraries_test');
+ }
+
+ /**
+ * Tests libraries detection and loading.
+ *
+ * @todo Better method name(s); split into detection/loading/overloading/etc.
+ */
+ function testLibraries() {
// Test that library information is found correctly.
$expected = array(
'name' => 'Example files',