You are here

public function DateTimePlusTest::testDateDiff 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::testDateDiff()
  2. 10 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateDiff()

Tests date diffs.

@dataProvider providerTestDateDiff

Parameters

mixed $input1: A DateTimePlus object.

mixed $input2: Date argument for DateTimePlus::diff method.

bool $absolute: Absolute flag for DateTimePlus::diff method.

\DateInterval $expected: The expected result of the DateTimePlus::diff operation.

File

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

Class

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

Namespace

Drupal\Tests\Component\Datetime

Code

public function testDateDiff($input1, $input2, $absolute, \DateInterval $expected) {
  $interval = $input1
    ->diff($input2, $absolute);
  $this
    ->assertEquals($interval, $expected);
}