function DateTimePlusTest::testDateTimezone

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateTimezone()
  2. 8.9.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateTimezone()
  3. 11.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateTimezone()

Tests that DrupalDateTime can detect the right timezone to use.

When specified or not.

@dataProvider providerTestDateTimezone

Parameters

mixed $input: Input argument for DateTimePlus.

mixed $timezone: Timezone argument for DateTimePlus.

string $expected_timezone: Expected timezone returned from DateTimePlus::getTimezone::getName().

string $message: Message to print on test failure.

File

core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php, line 288

Class

DateTimePlusTest
@coversDefaultClass \Drupal\Component\Datetime\DateTimePlus @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function testDateTimezone($input, $timezone, $expected_timezone, $message) : void {
    $date = new DateTimePlus($input, $timezone);
    $timezone = $date->getTimezone()
        ->getName();
    $this->assertEquals($timezone, $expected_timezone, $message);
}

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