diff --git a/core/modules/system/tests/src/Kernel/Mail/MailTest.php b/core/modules/system/tests/src/Kernel/Mail/MailTest.php index c03fe92..d441792 100644 --- a/core/modules/system/tests/src/Kernel/Mail/MailTest.php +++ b/core/modules/system/tests/src/Kernel/Mail/MailTest.php @@ -48,7 +48,10 @@ protected function setUp() { */ public function testPluggableFramework() { // Switch mail backends. - $this->config('system.mail')->set('interface.default', 'test_php_mail_failure')->save(); + // KernelTestBase enforces the usage of 'test_mail_collector' plugin to + // collect mail. Since we need to test this functionality itself, we + // manually configure the default mail interface. + $GLOBALS['config']['system.mail']['interface']['default'] = 'test_php_mail_failure'; // Get the default MailInterface class instance. $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'default', 'key' => 'default']); @@ -75,7 +78,11 @@ public function testPluggableFramework() { */ public function testErrorMessageDisplay() { // Switch mail backends. - $this->config('system.mail')->set('interface.default', 'test_php_mail_failure')->save(); + // KernelTestBase enforces the usage of 'test_mail_collector' plugin to + // collect mail. Since we need to test this functionality itself, we + // manually configure the default mail interface. + $GLOBALS['config']['system.mail']['interface']['default'] = 'test_php_mail_failure'; + // Test with errors displayed to users. \Drupal::service('plugin.manager.mail')->mail('default', 'default', 'test@example.com', 'en'); @@ -190,7 +197,10 @@ public function testFromAndReplyToHeader() { public function testConvertRelativeUrlsIntoAbsolute() { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $this->config('system.mail')->set('interface.default', 'test_html_mail_collector')->save(); + // KernelTestBase enforces the usage of 'test_mail_collector' plugin to + // collect mail. Since we need to test this functionality itself, we + // manually configure the default mail interface. + $GLOBALS['config']['system.mail']['interface']['default'] = 'test_html_mail_collector'; // Fetch the hostname and port for matching against. $http_host = \Drupal::request()->getSchemeAndHttpHost(); @@ -277,7 +287,10 @@ public function testConvertRelativeUrlsIntoAbsolute() { public function testRenderedElementsUseAbsolutePaths() { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $this->config('system.mail')->set('interface.default', 'test_html_mail_collector')->save(); + // KernelTestBase enforces the usage of 'test_mail_collector' plugin to + // collect mail. Since we need to test this functionality itself, we + // manually configure the default mail interface. + $GLOBALS['config']['system.mail']['interface']['default'] = 'test_html_mail_collector'; // Fetch the hostname and port for matching against. $http_host = \Drupal::request()->getSchemeAndHttpHost(); diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 5e14720..6cfbda5 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -384,7 +384,7 @@ private function bootKernel() { // tests from sending out emails and collect them in state instead. // While this should be enforced via settings.php prior to installation, // some tests expect to be able to test mail system implementations. - $this->config('system.mail')->set('interface.default', 'test_mail_collector')->save(); + $GLOBALS['config']['system.mail']['interface']['default'] = 'test_mail_collector'; // Manually configure the default file scheme so that modules that use file // functions don't have to install system and its configuration.