function DateTimePlusTest::testInvalidDates

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

Test invalid date handling.

@dataProvider providerTestInvalidDates

Parameters

mixed $input: Input argument for DateTimePlus.

string $timezone: Timezone argument for DateTimePlus.

string $format: Format argument for DateTimePlus.

string $message: Message to print if no errors are thrown by the invalid dates.

string $class: The Exception subclass to expect to be thrown.

File

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

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 testInvalidDates($input, $timezone, $format, $message, $class) {
    $this->expectException($class);
    DateTimePlus::createFromFormat($format, $input, $timezone);
}

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