diff --git a/includes/common.inc b/includes/common.inc index f54f29a..77ea1a9 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5142,8 +5142,6 @@ function drupal_cron_cleanup() { function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) { $config = conf_path(); - $profile = drupal_get_profile(); - $searchdir = array($directory); $files = array(); @@ -5151,8 +5149,14 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) // themes as organized by a distribution. It is pristine in the same way // that /modules is pristine for core; users should avoid changing anything // there in favor of sites/all or sites/ directories. - if (file_exists("profiles/$profile/$directory")) { - $searchdir[] = "profiles/$profile/$directory"; + // + // For SimpleTest to be able to test modules packaged together with a + // distribution we need to include the parent profile's search path. + $profiles = array(drupal_get_profile(), variable_get('simpletest_parent_profile', '')); + foreach ($profiles as $profile) { + if ($profile && file_exists("profiles/$profile/$directory")) { + $searchdir[] = "profiles/$profile/$directory"; + } } // Always search sites/all/* as well as the global directories diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 5c39cfc..5a94833 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1304,7 +1304,10 @@ class DrupalWebTestCase extends DrupalTestCase { variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); - // Include the testing profile. + // Include the testing profile and set the simpletest_parent_profile + // variable which is used to add the parent profile's search path to the + // child site's search paths. See drupal_system_listing(). + variable_set('simpletest_parent_profile', $this->originalProfile); variable_set('install_profile', $this->profile); $profile_details = install_profile_info($this->profile, 'en'); @@ -1499,6 +1502,9 @@ class DrupalWebTestCase extends DrupalTestCase { $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault; } + // Delete 'simpletest_parent_profile' variable. + variable_del('simpletest_parent_profile'); + // Close the CURL handler. $this->curlClose(); } diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test index e5b6042..b846124 100644 --- a/modules/simpletest/simpletest.test +++ b/modules/simpletest/simpletest.test @@ -503,3 +503,31 @@ class SimpleTestMissingDependentModuleUnitTest extends DrupalUnitTestCase { $this->fail(t('Running test with missing required module.')); } } + +/** + * Test that tests in modules bundled with an installation profile are found. + */ +class SimpleTestInstallationProfileTestsFoundTest extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Installation profile tests found', + 'description' => 'Verify that tests bundled with installation profiles are found', + 'group' => 'SimpleTest', + ); + } + + function setUp() { + // There is a test bundled with the drupal_system_listing_compatible_test module. + $this->profile = 'testing'; + parent::setUp('simpletest'); + + // Create and login user. + $admin_user = $this->drupalCreateUser(array('administer unit tests')); + $this->drupalLogin($admin_user); + } + + function testInstallationProfileTestsFound() { + $this->drupalGet('admin/config/development/testing'); + $this->assertText('Test class to verify installation profile tests are found'); + } +} 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 index 5ee352c..156b2f2 100644 --- 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 @@ -4,6 +4,7 @@ package = Testing version = VERSION core = 8.x hidden = TRUE +files[] = drupal_system_listing_compatible_test.test ; Information added by drupal.org packaging script on 2011-08-31 version = "8.x-dev" diff --git a/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.test b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.test new file mode 100644 index 0000000..541baa2 --- /dev/null +++ b/profiles/testing/modules/drupal_system_listing_compatible_test/drupal_system_listing_compatible_test.test @@ -0,0 +1,17 @@ + 'Test class to verify installation profile tests are found', + 'description' => "A test to test drupal_system_listing's ability to find tests that are bundled with installation profiles.", + 'group' => 'Installation profile test', + ); + } + + function testDrupalSystemListing() { + } +}