You are here

public function DrupalDateTimeTest::testInvalidDateDiff in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testInvalidDateDiff()
  2. 9 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::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/Core/Datetime/DrupalDateTimeTest.php, line 45

Class

DrupalDateTimeTest
@coversDefaultClass \Drupal\Core\Datetime\DrupalDateTime @group Datetime

Namespace

Drupal\Tests\Core\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);
}