function DateTimePlusTest::testUnserializeWithInvalidDateTimeObject

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::testUnserializeWithInvalidDateTimeObject()

Tests unserializing a payload whose $dateTimeObject is not a date.

File

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

Class

DateTimePlusTest
Tests Drupal\Component\Datetime\DateTimePlus.

Namespace

Drupal\Tests\Component\Datetime

Code

public function testUnserializeWithInvalidDateTimeObject() : void {
  $serialized = "O:38:\"Drupal\\Component\\Datetime\\DateTimePlus\":3:{s:11:\"\x00*\x00langcode\";N;s:9:\"\x00*\x00errors\";a:0:{}s:17:\"\x00*\x00dateTimeObject\";s:8:\"not-date\";}";
  $this->expectException(\TypeError::class);
  unserialize($serialized);
}

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