public function DrupalDateTimeTest::testChainableNonCallable in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testChainableNonCallable()
- 10 core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php \Drupal\Tests\Core\Datetime\DrupalDateTimeTest::testChainableNonCallable()
Tests that chained calls to non-existent functions throw an exception.
@covers ::__call
File
- core/
tests/ Drupal/ Tests/ Core/ Datetime/ DrupalDateTimeTest.php, line 209
Class
- DrupalDateTimeTest
- @coversDefaultClass \Drupal\Core\Datetime\DrupalDateTime @group Datetime
Namespace
Drupal\Tests\Core\DatetimeCode
public function testChainableNonCallable() {
$this
->expectException(\BadMethodCallException::class);
$this
->expectExceptionMessage('Call to undefined method Drupal\\Core\\Datetime\\DrupalDateTime::nonexistent()');
$tz = new \DateTimeZone(date_default_timezone_get());
$date = new DrupalDateTime('now', $tz, [
'langcode' => 'en',
]);
$date
->setTimezone(new \DateTimeZone('America/New_York'))
->nonexistent();
}