function DateTimePlusTest::testInvalidDateDiff

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

Tests date diff exception caused by invalid input.

@dataProvider providerTestInvalidDateDiff

Parameters

mixed $input1: A DateTimePlus object.

mixed $input2: Date argument for DateTimePlus::diff method.

bool $absolute: Absolute flag for DateTimePlus::diff method.

File

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

Class

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

Namespace

Drupal\Tests\Component\Datetime

Code

public function testInvalidDateDiff($input1, $input2, $absolute) {
    $this->expectException(\BadMethodCallException::class);
    $this->expectExceptionMessage('Method Drupal\\Component\\Datetime\\DateTimePlus::diff expects parameter 1 to be a \\DateTime or \\Drupal\\Component\\Datetime\\DateTimePlus object');
    $interval = $input1->diff($input2, $absolute);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.