diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php index 83f1048..f2a48f3 100755 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php @@ -41,6 +41,7 @@ public static function getInfo() { function setUp() { if (!$this->isInChildSite()) { + file_put_contents($this->siteDirectory. '/' . 'settings.testing.php', 'drupalLogin($this->drupalCreateUser(array('administer unit tests'))); @@ -188,6 +189,11 @@ function stubTest() { $this->drupalCreateUser(array($this->invalid_permission)); $this->pass(t('Test ID is @id.', array('@id' => $this->testId))); + // These two are tested by asserting the right number of passes and + // failures. + $this->assertTrue(file_exists(conf_path() . '/settings.testing.php')); + // Check the settings.testing.php file got included. + $this->assertTrue(function_exists('simpletest_test_stub_settings_function')); // Call trigger_error() without the required argument to trigger an E_WARNING. trigger_error(); @@ -234,7 +240,7 @@ function confirmStubTestResults() { $this->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()'); - $this->assertEqual('6 passes, 5 fails, 2 exceptions, 1 debug message', $this->childTestResults['summary']); + $this->assertEqual('8 passes, 5 fails, 2 exceptions, 1 debug message', $this->childTestResults['summary']); $this->test_ids[] = $test_id = $this->getTestIdFromResults(); $this->assertTrue($test_id, 'Found test ID in results.'); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 1a37920..7bf2ee7 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -818,7 +818,8 @@ protected function setUp() { // Copy and prepare an actual settings.php, so as to resemble a regular // installation. // Not using File API; a potential error must trigger a PHP warning. - copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php'); + $directory = DRUPAL_ROOT . '/' . $this->siteDirectory; + copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php'); // All file system paths are created by System module during installation. // @see system_requirements() @@ -842,6 +843,14 @@ protected function setUp() { 'required' => TRUE, ); $this->writeSettings($settings); + $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php'; + if (file_exists($settings_testing_file)) { + // Copy the testing specific overrides in place. + copy($settings_testing_file, $directory . '/settings.testing.php'); + // Add the name of the testing class to settings.php and include the + // testing specific overrides + file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) ."';\n" . 'include DRUPAL_ROOT . \'/\' . $conf_path . \'/settings.testing.php\';' ."\n", FILE_APPEND); + } // Since Drupal is bootstrapped already, install_begin_request() will not // bootstrap into DRUPAL_BOOTSTRAP_CONFIGURATION (again). Hence, we have to @@ -864,7 +873,7 @@ protected function setUp() { // directory has to be writable. // TestBase::restoreEnvironment() will delete the entire site directory. // Not using File API; a potential error must trigger a PHP warning. - chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777); + chmod($directory, 0777); $this->rebuildContainer();