|
26 | 26 | use Crell\Serde\Records\ClassWithReducibleProperty; |
27 | 27 | use Crell\Serde\Records\CompoundTypes; |
28 | 28 | use Crell\Serde\Records\DateTimeExample; |
| 29 | +use Crell\Serde\Records\DateTimeInterfaceExample; |
29 | 30 | use Crell\Serde\Records\DictionaryKeyTypes; |
30 | 31 | use Crell\Serde\Records\Drupal\EmailItem; |
31 | 32 | use Crell\Serde\Records\Drupal\FieldItemList; |
@@ -339,6 +340,11 @@ public static function round_trip_examples(): iterable |
339 | 340 | arrayMap: ['a' => [1, 2, 3]], |
340 | 341 | ), |
341 | 342 | ]; |
| 343 | + yield 'datetimeinterface_type' => [ |
| 344 | + 'data' => new DateTimeInterfaceExample( |
| 345 | + interfaceProperty: new \DateTimeImmutable('2025-12-25 12:34:56.789'), |
| 346 | + ), |
| 347 | + ]; |
342 | 348 | } |
343 | 349 |
|
344 | 350 | public static function value_object_flatten_examples(): \Generator |
@@ -1059,27 +1065,6 @@ public function datetime_fields_support_custom_output_format(): void |
1059 | 1065 | self::assertEquals($expected, $result); |
1060 | 1066 | } |
1061 | 1067 |
|
1062 | | - #[Test] |
1063 | | - public function datetime_field_can_be_datetimeinterface(): void |
1064 | | - { |
1065 | | - $s = new SerdeCommon(formatters: $this->formatters); |
1066 | | - |
1067 | | - $timeString = '2025-12-25 12:34:56.789'; |
1068 | | - $stampImmutable = new \DateTimeImmutable($timeString); |
1069 | | - |
1070 | | - $data = new class($stampImmutable) { |
1071 | | - public function __construct(public readonly \DateTimeInterface $stamp) {} |
1072 | | - }; |
1073 | | - |
1074 | | - $serialized = $s->serialize($data, $this->format); |
1075 | | - |
1076 | | - $this->validateSerialized($serialized, __FUNCTION__); |
1077 | | - |
1078 | | - $result = $s->deserialize($serialized, from: $this->format, to: get_class($data)); |
1079 | | - |
1080 | | - self::assertEquals($data, $result); |
1081 | | - } |
1082 | | - |
1083 | 1068 | #[Test] |
1084 | 1069 | public function unixtime_fields_in_range_are_supported(): void |
1085 | 1070 | { |
|
0 commit comments