function DateTimePlusTest::testChainableNonChainable

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testChainableNonChainable()
  2. 10 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 895

Class

DateTimePlusTest
@coversDefaultClass \Drupal\Component\Datetime\DateTimePlus @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function testChainableNonChainable() {
    $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.