diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 627f6dc..690bc8c 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -54,6 +54,13 @@ protected $databasePrefix = NULL; /** + * The site directory of the original parent site. + * + * @var string + */ + protected $originalSite; + + /** * The original file directory, before it was changed for testing purposes. * * @var string diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php index e0f949d..492b86f 100755 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php @@ -7,7 +7,6 @@ namespace Drupal\simpletest\Tests; -use Drupal\Core\Database\Driver\pgsql\Select; use Drupal\simpletest\WebTestBase; /** @@ -44,7 +43,34 @@ public static function getInfo() { function setUp() { if (!$this->isInChildSite()) { - file_put_contents($this->siteDirectory. '/' . 'settings.testing.php', 'siteDirectory. '/' . 'settings.testing.php', $php); + // @see \Drupal\system\Tests\DrupalKernel\DrupalKernelSiteTest + $class = __CLASS__; + $yaml = <<siteDirectory . '/testing.services.yml', $yaml); + parent::setUp(); // Create and log in an admin user. $this->drupalLogin($this->drupalCreateUser(array('administer unit tests'))); @@ -192,11 +218,14 @@ 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. + // These four assertions 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')); + // Check that the test-specific service file got loaded. + $this->assertTrue($this->container->has('site.service.yml')); + $this->assertIdentical(get_class($this->container->get('cache.backend.database')), 'Drupal\Core\Cache\MemoryBackendFactory'); // Call trigger_error() without the required argument to trigger an E_WARNING. trigger_error(); @@ -243,7 +272,7 @@ function confirmStubTestResults() { $this->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'SimpleTestTest.php', 'Drupal\simpletest\Tests\SimpleTestTest->stubTest()'); - $this->assertEqual('8 passes, 5 fails, 2 exceptions, 1 debug message', $this->childTestResults['summary']); + $this->assertEqual('10 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 1a494dd..963de4a 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -843,14 +843,21 @@ protected function setUp() { 'required' => TRUE, ); $this->writeSettings($settings); + + // Allow for test-specific overrides. $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php'; if (file_exists($settings_testing_file)) { - // Copy the testing specific overrides in place. + // 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); } + $settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml'; + if (file_exists($settings_services_file)) { + // Copy the testing-specific service overrides in place. + copy($settings_services_file, $directory . '/services.yml'); + } // Since Drupal is bootstrapped already, install_begin_request() will not // bootstrap into DRUPAL_BOOTSTRAP_CONFIGURATION (again). Hence, we have to