summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-15 00:37:08 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-15 00:37:08 +0000
commitd36b7bde4208dc08bb1a061ee45a090f69c82716 (patch)
treead936bb30eb87dbef2552836f941ca201cef622e
parenteed07e55dd0f4598979c1de79df0ca804a3cdcda (diff)
downloadbrdo-d36b7bde4208dc08bb1a061ee45a090f69c82716.tar.gz
brdo-d36b7bde4208dc08bb1a061ee45a090f69c82716.tar.bz2
#895140 follow-up by David_Rothstein: Tests to ensure older versions of modules are not chosen over new ones.
-rw-r--r--modules/simpletest/tests/common.test60
-rw-r--r--modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info8
-rw-r--r--modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module2
-rw-r--r--modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info8
-rw-r--r--modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module2
-rw-r--r--profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info8
-rw-r--r--profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module2
-rw-r--r--profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info11
-rw-r--r--profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module2
9 files changed, 103 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 82f8b2e39..83f2e9734 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1977,6 +1977,66 @@ class ParseInfoFilesTestCase extends DrupalWebTestCase {
}
/**
+ * Tests for the drupal_system_listing() function.
+ */
+class DrupalSystemListingTestCase extends DrupalWebTestCase {
+ /**
+ * Use the testing profile; this is needed for testDirectoryPrecedence().
+ */
+ protected $profile = 'testing';
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Drupal system listing',
+ 'description' => 'Tests the mechanism for scanning system directories in drupal_system_listing().',
+ 'group' => 'System',
+ );
+ }
+
+ /**
+ * Test that files in different directories take precedence as expected.
+ */
+ function testDirectoryPrecedence() {
+ // Define the module files we will search for, and the directory precedence
+ // we expect.
+ $expected_directories = array(
+ // When the copy of the module in the profile directory is incompatible
+ // with Drupal core, the copy in the core modules directory takes
+ // precedence.
+ 'drupal_system_listing_incompatible_test' => array(
+ 'modules/simpletest/tests',
+ 'profiles/testing/modules',
+ ),
+ // When both copies of the module are compatible with Drupal core, the
+ // copy in the profile directory takes precedence.
+ 'drupal_system_listing_compatible_test' => array(
+ 'profiles/testing/modules',
+ 'modules/simpletest/tests',
+ ),
+ );
+
+ // This test relies on two versions of the same module existing in
+ // different places in the filesystem. Without that, the test has no
+ // meaning, so assert their presence first.
+ foreach ($expected_directories as $module => $directories) {
+ foreach ($directories as $directory) {
+ $filename = "$directory/$module/$module.module";
+ $this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), t('@filename exists.', array('@filename' => $filename)));
+ }
+ }
+
+ // Now scan the directories and check that the files take precedence as
+ // expected.
+ $files = drupal_system_listing('/\.module$/', 'modules', 'name', 1);
+ foreach ($expected_directories as $module => $directories) {
+ $expected_directory = array_shift($directories);
+ $expected_filename = "$expected_directory/$module/$module.module";
+ $this->assertEqual($files[$module]->uri, $expected_filename, t('Module @module was found at @filename.', array('@module' => $module, '@filename' => $expected_filename)));
+ }
+ }
+}
+
+/**
* Tests for the format_date() function.
*/
class FormatDateUnitTest extends DrupalWebTestCase {
diff --git a/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info
new file mode 100644
index 000000000..155de2ed7
--- /dev/null
+++ b/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info
@@ -0,0 +1,8 @@
+; $Id$
+name = "Drupal system listing compatible test"
+description = "Support module for testing the drupal_system_listing function."
+package = Testing
+version = VERSION
+core = 7.x
+files[] = drupal_system_listing_compatible_test.module
+hidden = TRUE
diff --git a/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module b/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
new file mode 100644
index 000000000..13bb990c4
--- /dev/null
+++ b/modules/simpletest/tests/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
@@ -0,0 +1,2 @@
+<?php
+// $Id$
diff --git a/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info
new file mode 100644
index 000000000..491fbda2f
--- /dev/null
+++ b/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info
@@ -0,0 +1,8 @@
+; $Id$
+name = "Drupal system listing incompatible test"
+description = "Support module for testing the drupal_system_listing function."
+package = Testing
+version = VERSION
+core = 7.x
+files[] = drupal_system_listing_incompatible_test.module
+hidden = TRUE
diff --git a/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module b/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
new file mode 100644
index 000000000..13bb990c4
--- /dev/null
+++ b/modules/simpletest/tests/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
@@ -0,0 +1,2 @@
+<?php
+// $Id$
diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info
new file mode 100644
index 000000000..155de2ed7
--- /dev/null
+++ b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.info
@@ -0,0 +1,8 @@
+; $Id$
+name = "Drupal system listing compatible test"
+description = "Support module for testing the drupal_system_listing function."
+package = Testing
+version = VERSION
+core = 7.x
+files[] = drupal_system_listing_compatible_test.module
+hidden = TRUE
diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
new file mode 100644
index 000000000..13bb990c4
--- /dev/null
+++ b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.module
@@ -0,0 +1,2 @@
+<?php
+// $Id$
diff --git a/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info b/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info
new file mode 100644
index 000000000..37dbc986e
--- /dev/null
+++ b/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.info
@@ -0,0 +1,11 @@
+; $Id$
+name = "Drupal system listing incompatible test"
+description = "Support module for testing the drupal_system_listing function."
+package = Testing
+version = VERSION
+; This deliberately has the wrong core version, to test that it does not take
+; precedence over the version of the same module that is in the
+; modules/simpletest/tests directory.
+core = 6.x
+files[] = drupal_system_listing_incompatible_test.module
+hidden = TRUE
diff --git a/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module b/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
new file mode 100644
index 000000000..13bb990c4
--- /dev/null
+++ b/profiles/testing/modules/drupal_system_listing_incompatible_test/drupal_system_listing_incompatible_test.module
@@ -0,0 +1,2 @@
+<?php
+// $Id$