|
49 | 49 | use Crell\Serde\Records\MappedCollected\ThingC; |
50 | 50 | use Crell\Serde\Records\MappedCollected\ThingList; |
51 | 51 | use Crell\Serde\Records\MixedVal; |
| 52 | +use Crell\Serde\Records\MixedValObject; |
52 | 53 | use Crell\Serde\Records\MultiCollect\ThingOneA; |
53 | 54 | use Crell\Serde\Records\MultiCollect\ThingTwoC; |
54 | 55 | use Crell\Serde\Records\MultiCollect\Wrapper; |
@@ -1062,27 +1063,30 @@ public static function mixed_val_property_examples(): iterable |
1062 | 1063 | yield 'dict' => [new MixedVal(['a' => 'A', 'b' => 'B', 'c' => 'C'])]; |
1063 | 1064 | } |
1064 | 1065 |
|
1065 | | - public function mixed_val_property_validate(mixed $serialized, mixed $data): void |
| 1066 | + #[Test, DataProvider('mixed_val_property_object_examples')] |
| 1067 | + public function mixed_val_property_object(mixed $data): void |
1066 | 1068 | { |
1067 | | - } |
| 1069 | + $s = new SerdeCommon(formatters: $this->formatters); |
1068 | 1070 |
|
1069 | | - /** |
1070 | | - * This isn't a desired feature; it's just confirmation for the future why it is how it is. |
1071 | | - */ |
1072 | | - #[Test] |
1073 | | - public function mixed_val_object_does_not_serialize(): void |
1074 | | - { |
1075 | | - // MixedExporter sends the property value back through the Serialize pipeline |
1076 | | - // a second time with a new Field definition. However, that trips the circular |
1077 | | - // reference detection. Ideally we will fix that somehow, but I'm not sure how. |
1078 | | - // Importing an object to mixed will never work correctly. |
1079 | | - $this->expectException(CircularReferenceDetected::class); |
| 1071 | + $serialized = $s->serialize($data, $this->format); |
| 1072 | + |
| 1073 | + $this->mixed_val_property_validate($serialized, $data); |
1080 | 1074 |
|
1081 | | - $data = new MixedVal(new Point(3, 4, 5)); |
| 1075 | + $result = $s->deserialize($serialized, from: $this->format, to: MixedValObject::class); |
1082 | 1076 |
|
1083 | | - $s = new SerdeCommon(formatters: $this->formatters); |
| 1077 | + self::assertEquals($data, $result); |
| 1078 | + } |
1084 | 1079 |
|
1085 | | - $serialized = $s->serialize($data, $this->format); |
| 1080 | + public static function mixed_val_property_object_examples(): iterable |
| 1081 | + { |
| 1082 | + yield 'string' => [new MixedValObject('hello')]; |
| 1083 | + yield 'int' => [new MixedValObject(5)]; |
| 1084 | + yield 'float' => [new MixedValObject(3.14)]; |
| 1085 | + yield 'object' => [new MixedValObject(new Point(1, 2, 3))]; |
| 1086 | + } |
| 1087 | + |
| 1088 | + public function mixed_val_property_validate(mixed $serialized, mixed $data): void |
| 1089 | + { |
1086 | 1090 | } |
1087 | 1091 |
|
1088 | 1092 | #[Test] |
|
0 commit comments