function DateTimePlusTest::testChainableNonCallable

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

Tests that chained calls to non-existent functions throw an exception.

@legacy-covers ::__call

File

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

Class

DateTimePlusTest
Tests Drupal\Component\Datetime\DateTimePlus.

Namespace

Drupal\Tests\Component\Datetime

Code

public function testChainableNonCallable() : void {
  $this->expectException(\BadMethodCallException::class);
  $this->expectExceptionMessage('Call to undefined method Drupal\\Component\\Datetime\\DateTimePlus::nonexistent()');
  $date = new DateTimePlus('now', 'Australia/Sydney');
  $date->setTimezone(new \DateTimeZone('America/New_York'))
    ->nonexistent();
}

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