Commit 728c4ddd authored by catch's avatar catch
Browse files

Issue #2194445 by sun: Web tests of modules in a site-specific directory can...

Issue #2194445 by sun: Web tests of modules in a site-specific directory can no longer be run, because module is not in test site directory.
parent 3d24d1bb
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
namespace Drupal\Core; namespace Drupal\Core;
use Drupal\Component\Utility\Settings;
/** /**
* Returns information about system object files (modules, themes, etc.). * Returns information about system object files (modules, themes, etc.).
* *
...@@ -100,6 +102,16 @@ function scan($mask, $directory, $key = 'name') { ...@@ -100,6 +102,16 @@ function scan($mask, $directory, $key = 'name') {
$searchdir[] = $directory; $searchdir[] = $directory;
$searchdir[] = 'sites/all/' . $directory; $searchdir[] = 'sites/all/' . $directory;
// Simpletest uses the regular built-in multi-site functionality of Drupal
// for running web tests. As a consequence, extensions of the parent site
// located in a different site-specific directory are not discovered in a
// test site environment, because the site directories are not the same.
// Therefore, add the site directory of the parent site to the search paths,
// so that contained extensions are still discovered.
// @see \Drupal\simpletest\WebTestBase::setUp()
if ($parent_site = Settings::getSingleton()->get('test_parent_site')) {
$searchdir[] = $parent_site;
}
if (file_exists("$config/$directory")) { if (file_exists("$config/$directory")) {
$searchdir[] = "$config/$directory"; $searchdir[] = "$config/$directory";
} }
......
...@@ -968,6 +968,7 @@ private function prepareEnvironment() { ...@@ -968,6 +968,7 @@ private function prepareEnvironment() {
} }
// Backup current in-memory configuration. // Backup current in-memory configuration.
$this->originalSite = conf_path();
$this->originalSettings = settings()->getAll(); $this->originalSettings = settings()->getAll();
$this->originalConfig = $GLOBALS['config']; $this->originalConfig = $GLOBALS['config'];
......
...@@ -783,6 +783,14 @@ protected function setUp() { ...@@ -783,6 +783,14 @@ protected function setUp() {
'value' => $this->public_files_directory, 'value' => $this->public_files_directory,
'required' => TRUE, 'required' => TRUE,
); );
// Save the original site directory path, so that extensions in the
// site-specific directory can still be discovered in the test site
// environment.
// @see \Drupal\Core\SystemListing::scan()
$settings['settings']['test_parent_site'] = (object) array(
'value' => $this->originalSite,
'required' => TRUE,
);
// Add the parent profile's search path to the child site's search paths. // Add the parent profile's search path to the child site's search paths.
// @see drupal_system_listing() // @see drupal_system_listing()
$settings['conf']['simpletest.settings']['parent_profile'] = (object) array( $settings['conf']['simpletest.settings']['parent_profile'] = (object) array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment