class MailTest
Same name in this branch
- 8.9.x core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest
Same name in other branches
- 9 core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest
- 9 core/tests/Drupal/Tests/Component/Utility/MailTest.php \Drupal\Tests\Component\Utility\MailTest
- 10 core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest
- 11.x core/modules/system/tests/src/Kernel/Mail/MailTest.php \Drupal\Tests\system\Kernel\Mail\MailTest
Test mail helpers implemented in Mail component.
@group Utility
@coversDefaultClass \Drupal\Component\Utility\Mail
Hierarchy
- class \Drupal\Tests\Component\Utility\MailTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of MailTest
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ MailTest.php, line 15
Namespace
Drupal\Tests\Component\UtilityView source
class MailTest extends TestCase {
/**
* Tests RFC-2822 'display-name' formatter.
*
* @dataProvider providerTestDisplayName
* @covers ::formatDisplayName
*/
public function testFormatDisplayName($string, $safe_display_name) {
$this->assertEquals($safe_display_name, Mail::formatDisplayName($string));
}
/**
* Data provider for testFormatDisplayName().
*
* @see testFormatDisplayName()
*
* @return array
* An array containing a string and its 'display-name' safe value.
*/
public function providerTestDisplayName() {
return [
// Simple ASCII characters.
[
'Test site',
'Test site',
],
// ASCII with html entity.
[
'Test & site',
'Test & site',
],
// Non-ASCII characters.
[
'Tést site',
'=?UTF-8?B?VMOpc3Qgc2l0ZQ==?=',
],
// Non-ASCII with special characters.
[
'Tést; site',
'=?UTF-8?B?VMOpc3Q7IHNpdGU=?=',
],
// Non-ASCII with html entity.
[
'Tést; site',
'=?UTF-8?B?VMOpc3Q7IHNpdGU=?=',
],
// ASCII with special characters.
[
'Test; site',
'"Test; site"',
],
// ASCII with special characters as html entity.
[
'Test < site',
'"Test < site"',
],
// ASCII with special characters and '\'.
[
'Test; \\ "site"',
'"Test; \\\\ \\"site\\""',
],
// String already RFC-2822 compliant.
[
'"Test; site"',
'"Test; site"',
],
// String already RFC-2822 compliant.
[
'"Test; \\\\ \\"site\\""',
'"Test; \\\\ \\"site\\""',
],
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
MailTest::providerTestDisplayName | public | function | Data provider for testFormatDisplayName(). |
MailTest::testFormatDisplayName | public | function | Tests RFC-2822 'display-name' formatter. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.