public function DateTimePlusTest::providerTestDateTimezone in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 395 - Contains \Drupal\Tests\Component\Datetime\DateTimePlusTest.
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 array(
// Create a date object with an unspecified timezone, which should
// end up using the system timezone.
array(
$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.
array(
$date_string,
'America/Yellowknife',
'America/Yellowknife',
'DateTimePlus uses the specified timezone if provided.',
),
// Create a date object with a timezone object.
array(
$date_string,
new \DateTimeZone('Australia/Canberra'),
'Australia/Canberra',
'DateTimePlus uses the specified timezone if provided.',
),
// Create a date object with another date object.
array(
new DateTimePlus('now', 'Pacific/Midway'),
NULL,
'Pacific/Midway',
'DateTimePlus uses the specified timezone if provided.',
),
);
}