function DateTimePlusTest::testChainableNonChainable

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testChainableNonChainable()
  2. 8.9.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testChainableNonChainable()
  3. 11.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testChainableNonChainable()

Tests that non-chainable methods work.

@covers ::__call

File

core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php, line 897

Class

DateTimePlusTest
@coversDefaultClass \Drupal\Component\Datetime\DateTimePlus[[api-linebreak]] @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function testChainableNonChainable() : void {
  $datetime1 = new DateTimePlus('2009-10-11 12:00:00');
  $datetime2 = new DateTimePlus('2009-10-13 12:00:00');
  $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.