public function DateTimePlusTest::providerTestDateTimezone in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestDateTimezone()
- 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestDateTimezone()
Provides data for testDateTimezone.
Return value
array An array of arrays, each containing:
- 'date' - Date string or object for DateTimePlus.
- 'timezone' - Timezone string for DateTimePlus.
- 'expected' - Expected return from DateTimePlus::getTimezone()::getName().
- 'message' - Message to display on test failure.
See also
testDateTimezone
File
- core/
tests/ Drupal/ Tests/ Component/ Datetime/ DateTimePlusTest.php, line 502
Class
- DateTimePlusTest
- @coversDefaultClass \Drupal\Component\Datetime\DateTimePlus @group Datetime
Namespace
Drupal\Tests\Component\DatetimeCode
public function providerTestDateTimezone() {
// Use a common date for most of the tests.
$date_string = '2007-01-31 21:00:00';
// Detect the system timezone.
$system_timezone = date_default_timezone_get();
return [
// Create a date object with an unspecified timezone, which should
// end up using the system timezone.
[
$date_string,
NULL,
$system_timezone,
'DateTimePlus uses the system timezone when there is no site timezone.',
],
// Create a date object with a specified timezone name.
[
$date_string,
'America/Yellowknife',
'America/Yellowknife',
'DateTimePlus uses the specified timezone if provided.',
],
// Create a date object with a timezone object.
[
$date_string,
new \DateTimeZone('Australia/Canberra'),
'Australia/Canberra',
'DateTimePlus uses the specified timezone if provided.',
],
// Create a date object with another date object.
[
new DateTimePlus('now', 'Pacific/Midway'),
NULL,
'Pacific/Midway',
'DateTimePlus uses the specified timezone if provided.',
],
];
}