function MailTest::testErrorMessageDisplay
Same name in other branches
- 9 core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest::testErrorMessageDisplay()
- 10 core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest::testErrorMessageDisplay()
- 11.x core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest::testErrorMessageDisplay()
Assert that the pluggable mail system is functional.
File
-
core/
modules/ system/ tests/ src/ Kernel/ Mail/ MailTest.php, line 76
Class
- MailTest
- Performs tests on the pluggable mailing framework.
Namespace
Drupal\Tests\system\Kernel\MailCode
public function testErrorMessageDisplay() {
// Switch mail backends.
$this->configureDefaultMailInterface('test_php_mail_failure');
// Test with errors displayed to users.
\Drupal::service('plugin.manager.mail')->mail('default', 'default', 'test@example.com', 'en');
$messages = \Drupal::messenger()->messagesByType(MessengerInterface::TYPE_ERROR);
$this->assertEquals('Unable to send email. Contact the site administrator if the problem persists.', $messages[0]);
\Drupal::messenger()->deleteAll();
// Test without errors displayed to users.
\Drupal::service('plugin.manager.mail')->mail('default', 'default', 'test@example.com', 'en', [
'_error_message' => '',
]);
$this->assertEmpty(\Drupal::messenger()->messagesByType(MessengerInterface::TYPE_ERROR));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.