function DatetimeElementFormTest::testTimezoneHandling
Same name in other branches
- 8.9.x 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()
- 11.x 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 194
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']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.