function BrowserTestBaseTest::testLocalTimeZone

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testLocalTimeZone()
  2. 8.9.x core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testLocalTimeZone()
  3. 11.x core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testLocalTimeZone()

Tests the assumption that local time is in 'Australia/Sydney'.

File

core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php, line 489

Class

BrowserTestBaseTest
Tests BrowserTestBase functionality.

Namespace

Drupal\FunctionalTests

Code

public function testLocalTimeZone() : void {
    $expected = 'Australia/Sydney';
    // The 'Australia/Sydney' time zone is set in core/tests/bootstrap.php
    $this->assertEquals($expected, date_default_timezone_get());
    // The 'Australia/Sydney' time zone is also set in
    // FunctionalTestSetupTrait::initConfig().
    $config_factory = $this->container
        ->get('config.factory');
    $value = $config_factory->get('system.date')
        ->get('timezone.default');
    $this->assertEquals($expected, $value);
    // Test that users have the correct time zone set.
    $this->assertEquals($expected, $this->rootUser
        ->getTimeZone());
    $admin_user = $this->drupalCreateUser([
        'administer site configuration',
    ]);
    $this->assertEquals($expected, $admin_user->getTimeZone());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.