public function DrupalDateTimeTest::testDateDiff in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testDateDiff()
- 10 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\DatetimeCode
public function testDateDiff($input1, $input2, $absolute, \DateInterval $expected) {
$interval = $input1
->diff($input2, $absolute);
$this
->assertEquals($interval, $expected);
}