diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 3e54b3f085..32c97b63b5 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -324,10 +324,10 @@ public function getDatabasePrefix() { private function bootKernel() { $this->setSetting('container_yamls', []); // Allow for test-specific overrides. - $settings_services_file = $this->root . '/sites/default' . '/testing.services.yml'; + $settings_services_file = $this->root . '/sites/default/testing.services.yml'; if (file_exists($settings_services_file)) { // Copy the testing-specific service overrides in place. - $testing_services_file = $this->root . '/' . $this->siteDirectory . '/services.yml'; + $testing_services_file = $this->siteDirectory . '/services.yml'; copy($settings_services_file, $testing_services_file); $this->setSetting('container_yamls', [$testing_services_file]); } diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php index f44c9650f6..7ee0ff9ae9 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php +++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php @@ -17,6 +17,14 @@ class KernelTestBaseTest extends KernelTestBase { /** + * {@inheritdoc} + */ + protected function setUpFilesystem() { + parent::setUpFilesystem(); + file_put_contents($this->root . '/sites/default/testing.services.yml', "parameters:\n testing.services.included: true"); + } + + /** * @covers ::setUpBeforeClass */ public function testSetUpBeforeClass() { @@ -40,6 +48,7 @@ public function testBootEnvironment() { 'sync' => [], ], ], + 'services.yml' => "parameters:\n testing.services.included: true", ], ], ], @@ -216,6 +225,13 @@ public function testFileDefaultScheme() { } /** + * Tests that testing.service.yml files are loaded. + */ + public function testTestingServicesYml() { + $this->assertSame(TRUE, \Drupal::getContainer()->getParameter('testing.services.included')); + } + + /** * Tests the assumption that local time is in 'Australia/Sydney'. */ public function testLocalTimeZone() { @@ -300,6 +316,8 @@ protected function tearDown() { $this->assertTrue(empty($result), 'All test tables have been removed.'); } + + unlink($this->root . '/sites/default/testing.services.yml'); } }