You are here

public function DateTimePlusTest::testChainableNonChainable in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Tests that non-chainable methods work.

@covers ::__call

File

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

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'));
}