You are here

public function DateTimePlusTest::testDateFormat in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateFormat()
  2. 10 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateFormat()

Tests creating dates from format strings.

_date Format argument for DateTimePlus::format().

@dataProvider providerTestDateFormat

Parameters

string $input: Input argument for DateTimePlus.

string $timezone: Timezone argument for DateTimePlus.

string $format:

string $expected: Expected output from DateTimePlus::format().

File

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

Class

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

Namespace

Drupal\Tests\Component\Datetime

Code

public function testDateFormat($input, $timezone, $format, $format_date, $expected) {
  $date = DateTimePlus::createFromFormat($format, $input, $timezone);
  $value = $date
    ->format($format_date);
  $this
    ->assertEquals($expected, $value, sprintf("Test new DateTimePlus(%s, %s, %s): should be %s, found %s.", $input, $timezone, $format, $expected, $value));
}