3535use Patchlevel \Hydrator \Tests \Unit \Fixture \Status ;
3636use Patchlevel \Hydrator \Tests \Unit \Fixture \Wrapper ;
3737use PHPUnit \Framework \TestCase ;
38+ use Symfony \Component \TypeInfo \Type ;
3839
3940final class AttributeMetadataFactoryTest extends TestCase
4041{
@@ -91,6 +92,7 @@ public function testWithProperties(): void
9192
9293 self ::assertSame ('name ' , $ propertyMetadata ->propertyName ());
9394 self ::assertSame ('name ' , $ propertyMetadata ->fieldName ());
95+ self ::assertEquals (Type::nullable (Type::string ()), $ propertyMetadata ->type );
9496 self ::assertNull ($ propertyMetadata ->normalizer ());
9597 }
9698
@@ -136,6 +138,7 @@ public function __construct(
136138
137139 self ::assertSame ('name ' , $ propertyMetadata ->propertyName ());
138140 self ::assertSame ('name ' , $ propertyMetadata ->fieldName ());
141+ self ::assertEquals (Type::string (), $ propertyMetadata ->type );
139142 self ::assertNull ($ propertyMetadata ->normalizer ());
140143 }
141144
@@ -184,6 +187,7 @@ public function __construct(
184187
185188 self ::assertSame ('email ' , $ propertyMetadata ->propertyName ());
186189 self ::assertSame ('email ' , $ propertyMetadata ->fieldName ());
190+ self ::assertEquals (Type::object (Email::class), $ propertyMetadata ->type );
187191 self ::assertInstanceOf (EmailNormalizer::class, $ propertyMetadata ->normalizer ());
188192 }
189193
@@ -208,6 +212,7 @@ public function __construct(
208212
209213 self ::assertSame ('status ' , $ propertyMetadata ->propertyName ());
210214 self ::assertSame ('status ' , $ propertyMetadata ->fieldName ());
215+ self ::assertEquals (Type::enum (Status::class), $ propertyMetadata ->type );
211216
212217 $ normalizer = $ propertyMetadata ->normalizer ();
213218
@@ -245,6 +250,10 @@ public function testInferNormalizerWithGeneric(): void
245250
246251 $ propertyMetadata = $ metadata ->propertyForField ('email ' );
247252 self ::assertEquals (new ObjectNormalizer (Wrapper::class), $ propertyMetadata ->normalizer ());
253+ self ::assertEquals (
254+ Type::generic (Type::object (Wrapper::class), Type::object (Email::class)),
255+ $ propertyMetadata ->type ,
256+ );
248257 }
249258
250259 public function testInferNormalizerWithTemplate (): void
@@ -259,9 +268,23 @@ public function testInferNormalizerWithTemplate(): void
259268
260269 $ propertyMetadata = $ metadata ->propertyForField ('object ' );
261270 self ::assertEquals (new ObjectNormalizer (Wrapper::class), $ propertyMetadata ->normalizer ());
271+ self ::assertEquals (
272+ Type::generic (Type::object (Wrapper::class), Type::object (Email::class)),
273+ $ propertyMetadata ->type ,
274+ );
262275
263276 $ propertyMetadata = $ metadata ->propertyForField ('scalar ' );
264277 self ::assertEquals (new ObjectNormalizer (Wrapper::class), $ propertyMetadata ->normalizer ());
278+
279+ self ::assertEquals (
280+ Type::nullable (
281+ Type::generic (
282+ Type::object (Wrapper::class),
283+ Type::string (),
284+ ),
285+ ),
286+ $ propertyMetadata ->type ,
287+ );
265288 }
266289
267290 public function testExtends (): void
0 commit comments