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. 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 890

Class

DateTimePlusTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Datetime%21DateTimePlus.php/class/DateTimePlus/8.9.x" title="Wraps DateTime()." class="local">\Drupal\Component\Datetime\DateTimePlus</a> @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.