function DateTest::testRfc2822DateFormat
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::testRfc2822DateFormat()
Tests that an RFC2822 formatted date always returns an English string.
@covers ::format
See also
http://www.faqs.org/rfcs/rfc2822.html
File
-
core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateTest.php, line 437
Class
- DateTest
- @coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testRfc2822DateFormat() : void {
$timestamp = 1549110600;
$langcodes = array_keys(LanguageManager::getStandardLanguageList());
$langcodes[] = NULL;
foreach ($langcodes as $langcode) {
$formatted_date = $this->dateFormatter
->format($timestamp, 'custom', 'r', 'Europe/Berlin', $langcode);
// Check that RFC2822 format date is returned regardless of langcode.
$this->assertSame('Sat, 02 Feb 2019 13:30:00 +0100', $formatted_date);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.