|
4 | 4 |
|
5 | 5 | use Nuxtifyts\PhpDto\Attributes\Property\Computed; |
6 | 6 | use Nuxtifyts\PhpDto\Attributes\Property\WithRefiner; |
7 | | -use Nuxtifyts\PhpDto\Contexts\ClassContext; |
8 | 7 | use Nuxtifyts\PhpDto\Contexts\PropertyContext; |
9 | 8 | use Nuxtifyts\PhpDto\Contexts\TypeContext; |
10 | 9 | use Nuxtifyts\PhpDto\Data; |
11 | 10 | use Nuxtifyts\PhpDto\DataRefiners\DateTimeRefiner; |
12 | 11 | use Nuxtifyts\PhpDto\Enums\Property\Type; |
| 12 | +use Nuxtifyts\PhpDto\Exceptions\UnsupportedTypeException; |
13 | 13 | use Nuxtifyts\PhpDto\Serializers\ScalarTypeSerializer; |
14 | 14 | use Nuxtifyts\PhpDto\Tests\Dummies\ComputedPropertiesData; |
15 | 15 | use Nuxtifyts\PhpDto\Tests\Dummies\Enums\YesNoBackedEnum; |
|
31 | 31 | #[CoversClass(TypeContext::class)] |
32 | 32 | #[CoversClass(Computed::class)] |
33 | 33 | #[CoversClass(WithRefiner::class)] |
| 34 | +#[CoversClass(UnsupportedTypeException::class)] |
34 | 35 | #[UsesClass(ComputedPropertiesData::class)] |
35 | 36 | #[UsesClass(ScalarTypeSerializer::class)] |
36 | 37 | #[UsesClass(PersonData::class)] |
@@ -80,6 +81,24 @@ public function can_resolve_serializers_of_property(): void |
80 | 81 | self::assertInstanceOf(ScalarTypeSerializer::class, $serializers[0]); |
81 | 82 | } |
82 | 83 |
|
| 84 | + /** |
| 85 | + * @throws Throwable |
| 86 | + */ |
| 87 | + #[Test] |
| 88 | + public function will_throw_an_exception_if_property_type_is_not_supported(): void |
| 89 | + { |
| 90 | + $object = new readonly class ('') extends Data { |
| 91 | + public function __construct( |
| 92 | + public mixed $value |
| 93 | + ) { |
| 94 | + } |
| 95 | + }; |
| 96 | + |
| 97 | + $reflectionProperty = new ReflectionProperty($object::class, 'value'); |
| 98 | + self::expectException(UnsupportedTypeException::class); |
| 99 | + PropertyContext::getInstance($reflectionProperty); |
| 100 | + } |
| 101 | + |
83 | 102 | /** |
84 | 103 | * @throws Throwable |
85 | 104 | */ |
|
0 commit comments