public function DatetimeElementFormTest::testTimezoneHandling in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::testTimezoneHandling()
- 10 core/tests/Drupal/KernelTests/Core/Datetime/DatetimeElementFormTest.php \Drupal\KernelTests\Core\Datetime\DatetimeElementFormTest::testTimezoneHandling()
Tests proper timezone handling of the Datetime element.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Datetime/ DatetimeElementFormTest.php, line 114
Class
- DatetimeElementFormTest
- Tests DatetimeElement functionality.
Namespace
Drupal\KernelTests\Core\DatetimeCode
public function testTimezoneHandling() {
// Render the form once with the site's timezone.
$form = \Drupal::formBuilder()
->getForm($this);
$this
->render($form);
$this
->assertEquals('Australia/Sydney', $form['datetime_element']['#date_timezone']);
// Mimic a user with a different timezone than Australia/Sydney.
date_default_timezone_set('UTC');
$form = \Drupal::formBuilder()
->getForm($this);
$this
->render($form);
$this
->assertEquals('UTC', $form['datetime_element']['#date_timezone']);
}