|
8 | 8 | use Nuxtifyts\PhpDto\Exceptions\SerializeException;
|
9 | 9 | use Nuxtifyts\PhpDto\Pipelines\DeserializePipeline\DeserializePipelinePassable;
|
10 | 10 | use Nuxtifyts\PhpDto\Pipelines\DeserializePipeline\RefineDataPipe;
|
| 11 | +use Nuxtifyts\PhpDto\Serializers\BackedEnumSerializer; |
| 12 | +use Nuxtifyts\PhpDto\Serializers\DataSerializer; |
| 13 | +use Nuxtifyts\PhpDto\Serializers\DateTimeSerializer; |
11 | 14 | use Nuxtifyts\PhpDto\Support\Passable;
|
12 | 15 | use Nuxtifyts\PhpDto\Support\Pipe;
|
13 | 16 | use Nuxtifyts\PhpDto\Support\Pipeline;
|
|
32 | 35 | use PHPUnit\Framework\Attributes\Test;
|
33 | 36 | use PHPUnit\Framework\Attributes\UsesClass;
|
34 | 37 | use Throwable;
|
| 38 | +use DateTimeInterface; |
35 | 39 |
|
36 | 40 | #[CoversClass(Data::class)]
|
37 | 41 | #[CoversClass(DeserializeException::class)]
|
|
41 | 45 | #[CoversClass(DeserializePipelinePassable::class)]
|
42 | 46 | #[CoversClass(RefineDataPipe::class)]
|
43 | 47 | #[CoversClass(Passable::class)]
|
| 48 | +#[CoversClass(DateTimeSerializer::class)] |
| 49 | +#[CoversClass(DataSerializer::class)] |
| 50 | +#[CoversClass(BackedEnumSerializer::class)] |
44 | 51 | #[UsesClass(PersonData::class)]
|
45 | 52 | #[UsesClass(UnionTypedData::class)]
|
46 | 53 | #[UsesClass(YesOrNoData::class)]
|
@@ -271,6 +278,41 @@ public static function will_perform_serialization_and_deserialization_data_provi
|
271 | 278 | ],
|
272 | 279 | 'expectedSerializedData' => $data
|
273 | 280 | ],
|
| 281 | + 'Refundable item data 3' => [ |
| 282 | + 'dtoClass' => RefundableItemData::class, |
| 283 | + 'data' => $data = [ |
| 284 | + 'id' => 'id2', |
| 285 | + 'refundable' => YesNoBackedEnum::NO, |
| 286 | + 'refundableUntil' => null |
| 287 | + ], |
| 288 | + 'expectedProperties' => [ |
| 289 | + 'id' => 'id2', |
| 290 | + 'refundable' => YesNoBackedEnum::NO, |
| 291 | + 'refundableUntil' => null |
| 292 | + ], |
| 293 | + 'expectedSerializedData' => [ |
| 294 | + ...$data, |
| 295 | + 'refundable' => YesNoBackedEnum::NO->value |
| 296 | + ] |
| 297 | + ], |
| 298 | + 'Refundable item data 4' => [ |
| 299 | + 'dtoClass' => RefundableItemData::class, |
| 300 | + 'data' => $data = [ |
| 301 | + 'id' => 'id', |
| 302 | + 'refundable' => YesNoBackedEnum::YES->value, |
| 303 | + 'refundableUntil' => new DateTimeImmutable('2021-01-01T00:00:00+00:00') |
| 304 | + ], |
| 305 | + 'expectedProperties' => [ |
| 306 | + 'id' => 'id', |
| 307 | + 'refundable' => YesNoBackedEnum::YES, |
| 308 | + 'refundableUntil' => new DateTimeImmutable('2021-01-01T00:00:00+00:00') |
| 309 | + ], |
| 310 | + 'expectedSerializedData' => [ |
| 311 | + ...$data, |
| 312 | + 'refundableUntil' => new DateTimeImmutable('2021-01-01T00:00:00+00:00') |
| 313 | + ->format(DateTimeInterface::ATOM) |
| 314 | + ] |
| 315 | + ], |
274 | 316 | 'Address data 1' => [
|
275 | 317 | 'dtoClass' => AddressData::class,
|
276 | 318 | 'data' => $data = [
|
@@ -469,6 +511,36 @@ public static function will_perform_serialization_and_deserialization_data_provi
|
469 | 511 | ],
|
470 | 512 | 'expectedSerializedData' => $data
|
471 | 513 | ],
|
| 514 | + 'User group data 3' => [ |
| 515 | + 'dtoClass' => UserGroupData::class, |
| 516 | + 'data' => $data = [ |
| 517 | + 'name' => 'Group name 2', |
| 518 | + 'users' => [ |
| 519 | + new UserData('John', 'Doe'), |
| 520 | + new UserData('Jane', 'Doe') |
| 521 | + ] |
| 522 | + ], |
| 523 | + 'expectedProperties' => [ |
| 524 | + 'name' => 'Group name 2', |
| 525 | + 'users' => [ |
| 526 | + new UserData('John', 'Doe'), |
| 527 | + new UserData('Jane', 'Doe') |
| 528 | + ] |
| 529 | + ], |
| 530 | + 'expectedSerializedData' => [ |
| 531 | + ...$data, |
| 532 | + 'users' => [ |
| 533 | + [ |
| 534 | + 'firstName' => 'John', |
| 535 | + 'lastName' => 'Doe' |
| 536 | + ], |
| 537 | + [ |
| 538 | + 'firstName' => 'Jane', |
| 539 | + 'lastName' => 'Doe' |
| 540 | + ] |
| 541 | + ] |
| 542 | + ] |
| 543 | + ], |
472 | 544 | 'Computed properties data' => [
|
473 | 545 | 'dtoClass' => ComputedPropertiesData::class,
|
474 | 546 | 'data' => $data = [
|
|
0 commit comments