You are here

public function DrupalDateTimeTest::testDateDiff in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDateDiff()
  2. 9 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDateDiff()

Tests date diffs.

@dataProvider providerTestDateDiff

Parameters

mixed $input1: A DrupalDateTime object.

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

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

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

File

core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php, line 28

Class

DrupalDateTimeTest
@coversDefaultClass \Drupal\Core\Datetime\DrupalDateTime @group Datetime

Namespace

Drupal\Tests\Core\Datetime

Code

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