You are here

public function BrowserTestBaseTest::testLocalTimeZone in Drupal 9

Same name and namespace in other branches
  1. 8 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 768

Class

BrowserTestBaseTest
Tests BrowserTestBase functionality.

Namespace

Drupal\FunctionalTests

Code

public function testLocalTimeZone() {
  $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());
}