public function DateTest::testGetSampleDateFormats in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Datetime/DateTest.php \Drupal\Tests\Core\Datetime\DateTest::testGetSampleDateFormats()
Tests the getSampleDateFormats method.
@covers \Drupal\Core\Datetime\DateFormatter::getSampleDateFormats
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DateTest.php, line 161
Class
- DateTest
- @coversDefaultClass \Drupal\Core\Datetime\DateFormatter @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testGetSampleDateFormats() {
$timestamp = strtotime('2015-03-22 14:23:00');
$expected = $this->dateFormatter
->getSampleDateFormats('en', $timestamp, 'Australia/Sydney');
// Removed characters related to timezone 'e' and 'T', as test does not have
// timezone set.
$date_characters = 'dDjlNSwzWFmMntLoYyaABgGhHisuIOPZcrU';
$date_chars = str_split($date_characters);
foreach ($date_chars as $val) {
$this
->assertEquals($expected[$val], date($val, $timestamp));
}
}