function DrupalDateTimeTest::testDateDiff

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDateDiff()
  2. 10 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDateDiff()
  3. 11.x core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDateDiff()

Test 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);
}

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