function DateTimePlusTest::testTimestamp
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testTimestamp()
- 8.9.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testTimestamp()
- 10 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testTimestamp()
Tests creating dates from timestamps, and manipulating timezones.
@dataProvider providerTestTimestamp
Parameters
int $input: Input argument for DateTimePlus::createFromTimestamp().
array $initial: An array containing:
- 'timezone_initial' - Timezone argument for DateTimePlus.
- 'format_initial' - Format argument for DateTimePlus.
- 'expected_initial_date' - Expected output from DateTimePlus::format().
- 'expected_initial_timezone' - Expected output from DateTimePlus::getTimeZone()::getName().
- 'expected_initial_offset' - Expected output from DateTimePlus::getOffset().
array $transform: An array containing:
- 'timezone_transform' - Argument to transform date to another timezone via DateTimePlus::setTimezone().
- 'format_transform' - Format argument to use when transforming date to another timezone.
- 'expected_transform_date' - Expected output from DateTimePlus::format(), after timezone transform.
- 'expected_transform_timezone' - Expected output from DateTimePlus::getTimeZone()::getName(), after timezone transform.
- 'expected_transform_offset' - Expected output from DateTimePlus::getOffset(), after timezone transform.
File
-
core/
tests/ Drupal/ Tests/ Component/ Datetime/ DateTimePlusTest.php, line 162
Class
- DateTimePlusTest
- @coversDefaultClass \Drupal\Component\Datetime\DateTimePlus @group Datetime
Namespace
Drupal\Tests\Component\DatetimeCode
public function testTimestamp($input, array $initial, array $transform) : void {
// Initialize a new date object.
$date = DateTimePlus::createFromTimestamp($input, $initial['timezone']);
$this->assertDateTimestamp($date, $input, $initial, $transform);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.