function DateTimePlusTest::testDateDiff

Same name in other branches
  1. 9 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()
  3. 11.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateDiff()

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

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