TimeZoneTest.php

Same filename in this branch
  1. 8.9.x core/modules/system/tests/src/Kernel/Timezone/TimezoneTest.php
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
Same filename in other branches
  1. 9 core/modules/system/tests/src/Kernel/Timezone/TimezoneTest.php
  2. 9 core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
  3. 10 core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
  4. 11.x core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php

Namespace

Drupal\simpletest\Tests

File

core/modules/simpletest/src/Tests/TimeZoneTest.php

View source
<?php

namespace Drupal\simpletest\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * This test will check WebTestBase's default time zone handling.
 *
 * @group simpletest
 * @group WebTestBase
 */
class TimeZoneTest extends WebTestBase {
    
    /**
     * A user with administrative privileges.
     */
    protected $adminUser;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() {
        parent::setUp();
        $this->adminUser = $this->drupalCreateUser([
            'administer site configuration',
        ]);
    }
    
    /**
     * Tests that user accounts have the default time zone set.
     */
    public function testAccountTimeZones() {
        $expected = 'Australia/Sydney';
        $this->assertEqual($this->rootUser
            ->getTimeZone(), $expected, 'Root user has correct time zone.');
        $this->assertEqual($this->adminUser
            ->getTimeZone(), $expected, 'Admin user has correct time zone.');
    }

}

Classes

Title Deprecated Summary
TimeZoneTest This test will check WebTestBase's default time zone handling.

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