function DrupalDateTimeTest::testChainableNonChainable
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testChainableNonChainable()
- 10 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testChainableNonChainable()
- 11.x core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testChainableNonChainable()
Tests that non-chainable methods work.
@covers ::__call
File
-
core/
tests/ Drupal/ Tests/ Core/ Datetime/ DrupalDateTimeTest.php, line 195
Class
- DrupalDateTimeTest
- @coversDefaultClass \Drupal\Core\Datetime\DrupalDateTime @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testChainableNonChainable() {
$tz = new \DateTimeZone(date_default_timezone_get());
$datetime1 = new DrupalDateTime('2009-10-11 12:00:00', $tz, [
'langcode' => 'en',
]);
$datetime2 = new DrupalDateTime('2009-10-13 12:00:00', $tz, [
'langcode' => 'en',
]);
$interval = $datetime1->diff($datetime2);
$this->assertInstanceOf(\DateInterval::class, $interval);
$this->assertEquals('+2 days', $interval->format('%R%a days'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.