Issue #911354 by adrian, boombatower, jhedstrom, sun, yhahn, langworthy, dixon_, jrbeeman: Fixed Tests in profiles/[name]/modules cannot be run and cannot use a different profile for running tests.
parent
bb3f7e97c3
commit
a71a3f59c8
|
@ -5230,8 +5230,6 @@ function drupal_cron_cleanup() {
|
||||||
function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
|
function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
|
||||||
$config = conf_path();
|
$config = conf_path();
|
||||||
|
|
||||||
$profile = drupal_get_profile();
|
|
||||||
|
|
||||||
$searchdir = array($directory);
|
$searchdir = array($directory);
|
||||||
$files = array();
|
$files = array();
|
||||||
|
|
||||||
|
@ -5239,8 +5237,24 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
|
||||||
// themes as organized by a distribution. It is pristine in the same way
|
// themes as organized by a distribution. It is pristine in the same way
|
||||||
// that /modules is pristine for core; users should avoid changing anything
|
// that /modules is pristine for core; users should avoid changing anything
|
||||||
// there in favor of sites/all or sites/<domain> directories.
|
// there in favor of sites/all or sites/<domain> directories.
|
||||||
if (file_exists("profiles/$profile/$directory")) {
|
$profiles = array();
|
||||||
$searchdir[] = "profiles/$profile/$directory";
|
$profile = drupal_get_profile();
|
||||||
|
// For SimpleTest to be able to test modules packaged together with a
|
||||||
|
// distribution we need to include the profile of the parent site (in which
|
||||||
|
// test runs are triggered).
|
||||||
|
if (drupal_valid_test_ua()) {
|
||||||
|
$testing_profile = variable_get('simpletest_parent_profile', FALSE);
|
||||||
|
if ($testing_profile && $testing_profile != $profile) {
|
||||||
|
$profiles[] = $testing_profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// In case both profile directories contain the same extension, the actual
|
||||||
|
// profile always has precedence.
|
||||||
|
$profiles[] = $profile;
|
||||||
|
foreach ($profiles as $profile) {
|
||||||
|
if (file_exists("profiles/$profile/$directory")) {
|
||||||
|
$searchdir[] = "profiles/$profile/$directory";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always search sites/all/* as well as the global directories.
|
// Always search sites/all/* as well as the global directories.
|
||||||
|
|
|
@ -1344,6 +1344,12 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||||
variable_set('file_private_path', $private_files_directory);
|
variable_set('file_private_path', $private_files_directory);
|
||||||
variable_set('file_temporary_path', $temp_files_directory);
|
variable_set('file_temporary_path', $temp_files_directory);
|
||||||
|
|
||||||
|
// Set the 'simpletest_parent_profile' variable to add the parent profile's
|
||||||
|
// search path to the child site's search paths.
|
||||||
|
// @see drupal_system_listing()
|
||||||
|
// @todo This may need to be primed like 'install_profile' above.
|
||||||
|
variable_set('simpletest_parent_profile', $this->originalProfile);
|
||||||
|
|
||||||
// Include the testing profile.
|
// Include the testing profile.
|
||||||
variable_set('install_profile', $this->profile);
|
variable_set('install_profile', $this->profile);
|
||||||
$profile_details = install_profile_info($this->profile, 'en');
|
$profile_details = install_profile_info($this->profile, 'en');
|
||||||
|
|
|
@ -567,3 +567,91 @@ class SimpleTestBrokenSetUp extends DrupalWebTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that tests bundled with installation profile modules are found.
|
||||||
|
*/
|
||||||
|
class SimpleTestInstallationProfileModuleTestsTestCase extends DrupalWebTestCase {
|
||||||
|
/**
|
||||||
|
* Use the Testing profile.
|
||||||
|
*
|
||||||
|
* The Testing profile contains drupal_system_listing_compatible_test.test,
|
||||||
|
* which attempts to:
|
||||||
|
* - run tests using the Minimal profile (which does not contain the
|
||||||
|
* drupal_system_listing_compatible_test.module)
|
||||||
|
* - but still install the drupal_system_listing_compatible_test.module
|
||||||
|
* contained in the Testing profile.
|
||||||
|
*
|
||||||
|
* @see DrupalSystemListingCompatibleTestCase
|
||||||
|
*/
|
||||||
|
protected $profile = 'testing';
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Installation profile module tests',
|
||||||
|
'description' => 'Verifies that tests bundled with installation profile modules are found.',
|
||||||
|
'group' => 'SimpleTest',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
parent::setUp(array('simpletest'));
|
||||||
|
|
||||||
|
$this->admin_user = $this->drupalCreateUser(array('administer unit tests'));
|
||||||
|
$this->drupalLogin($this->admin_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests existence of test case located in an installation profile module.
|
||||||
|
*/
|
||||||
|
function testInstallationProfileTests() {
|
||||||
|
$this->drupalGet('admin/config/development/testing');
|
||||||
|
$this->assertText('Installation profile module tests helper');
|
||||||
|
$edit = array(
|
||||||
|
'DrupalSystemListingCompatibleTestCase' => TRUE,
|
||||||
|
);
|
||||||
|
$this->drupalPost(NULL, $edit, t('Run tests'));
|
||||||
|
$this->assertText('DrupalSystemListingCompatibleTestCase test executed.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that tests in other installation profiles are not found.
|
||||||
|
*
|
||||||
|
* @see SimpleTestInstallationProfileModuleTestsTestCase
|
||||||
|
*/
|
||||||
|
class SimpleTestOtherInstallationProfileModuleTestsTestCase extends DrupalWebTestCase {
|
||||||
|
/**
|
||||||
|
* Use the Minimal profile.
|
||||||
|
*
|
||||||
|
* The Testing profile contains drupal_system_listing_compatible_test.test,
|
||||||
|
* which should not be found.
|
||||||
|
*
|
||||||
|
* @see SimpleTestInstallationProfileModuleTestsTestCase
|
||||||
|
* @see DrupalSystemListingCompatibleTestCase
|
||||||
|
*/
|
||||||
|
protected $profile = 'minimal';
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Other Installation profiles',
|
||||||
|
'description' => 'Verifies that tests in other installation profiles are not found.',
|
||||||
|
'group' => 'SimpleTest',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
parent::setUp(array('simpletest'));
|
||||||
|
|
||||||
|
$this->admin_user = $this->drupalCreateUser(array('administer unit tests'));
|
||||||
|
$this->drupalLogin($this->admin_user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that tests located in another installation profile do not appear.
|
||||||
|
*/
|
||||||
|
function testOtherInstallationProfile() {
|
||||||
|
$this->drupalGet('admin/config/development/testing');
|
||||||
|
$this->assertNoText('Installation profile module tests helper');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,3 +4,4 @@ package = Testing
|
||||||
version = VERSION
|
version = VERSION
|
||||||
core = 7.x
|
core = 7.x
|
||||||
hidden = TRUE
|
hidden = TRUE
|
||||||
|
files[] = drupal_system_listing_compatible_test.test
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to verify tests in installation profile modules.
|
||||||
|
*/
|
||||||
|
class DrupalSystemListingCompatibleTestCase extends DrupalWebTestCase {
|
||||||
|
/**
|
||||||
|
* Use the Minimal profile.
|
||||||
|
*
|
||||||
|
* This test needs to use a different installation profile than the test which
|
||||||
|
* asserts that this test is found.
|
||||||
|
*
|
||||||
|
* @see SimpleTestInstallationProfileModuleTestsTestCase
|
||||||
|
*/
|
||||||
|
protected $profile = 'minimal';
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Installation profile module tests helper',
|
||||||
|
'description' => 'Verifies that tests in installation profile modules are found and may use another profile for running tests.',
|
||||||
|
'group' => 'Installation profile',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
// Attempt to install a module in Testing profile, while this test runs with
|
||||||
|
// a different profile.
|
||||||
|
parent::setUp(array('drupal_system_listing_compatible_test'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-empty test* method required to executed the test case class.
|
||||||
|
*/
|
||||||
|
function testDrupalSystemListing() {
|
||||||
|
$this->pass(__CLASS__ . ' test executed.');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue