@@ -154,6 +154,7 @@ protected static function getContent($key)
154154 $ outputs ['data_float ' ] = '{"data":1.236} ' ;
155155 $ outputs ['data_bool ' ] = '{"data":false} ' ;
156156 $ outputs ['data_string ' ] = '{"data":"foo"} ' ;
157+ $ outputs ['data_array ' ] = '{"data":[1,2,3]} ' ;
157158 $ outputs ['data_true ' ] = '{"data":true} ' ;
158159 $ outputs ['data_false ' ] = '{"data":false} ' ;
159160 $ outputs ['data_author ' ] = '{"data":{"full_name":"foo"}} ' ;
@@ -443,46 +444,30 @@ public static function getTypeHintedArraysAndStdClass()
443444 ];
444445 }
445446
446- public function testDeserializingUnionProperties ()
447+ public static function getSimpleUnionProperties (): iterable
447448 {
448- if (PHP_VERSION_ID < 80000 ) {
449- $ this ->markTestSkipped (sprintf ('%s requires PHP 8.0 ' , TypedPropertiesDriver::class));
450-
451- return ;
452- }
453-
454- $ object = new UnionTypedProperties (10000 );
455- self ::assertEquals ($ object , $ this ->deserialize (static ::getContent ('data_integer ' ), UnionTypedProperties::class));
456-
457- $ object = new UnionTypedProperties (1.236 );
458- self ::assertEquals ($ object , $ this ->deserialize (static ::getContent ('data_float ' ), UnionTypedProperties::class));
459-
460- $ object = new UnionTypedProperties (false );
461- self ::assertEquals ($ object , $ this ->deserialize (static ::getContent ('data_bool ' ), UnionTypedProperties::class));
462-
463- $ object = new UnionTypedProperties ('foo ' );
464- self ::assertEquals ($ object , $ this ->deserialize (static ::getContent ('data_string ' ), UnionTypedProperties::class));
449+ yield 'int ' => [10000 , 'data_integer ' ];
450+ yield [1.236 , 'data_float ' ];
451+ yield [false , 'data_bool ' ];
452+ yield ['foo ' , 'data_string ' ];
453+ yield [[1 , 2 , 3 ], 'data_array ' ];
465454 }
466455
467- public function testSerializingUnionProperties ()
456+ /**
457+ * @dataProvider getSimpleUnionProperties
458+ */
459+ #[DataProvider('getSimpleUnionProperties ' )]
460+ public function testUnionProperties ($ data , string $ expected ): void
468461 {
469462 if (PHP_VERSION_ID < 80000 ) {
470463 $ this ->markTestSkipped (sprintf ('%s requires PHP 8.0 ' , TypedPropertiesDriver::class));
471464
472465 return ;
473466 }
474467
475- $ serialized = $ this ->serialize (new UnionTypedProperties (10000 ));
476- self ::assertEquals (static ::getContent ('data_integer ' ), $ serialized );
477-
478- $ serialized = $ this ->serialize (new UnionTypedProperties (1.236 ));
479- self ::assertEquals (static ::getContent ('data_float ' ), $ serialized );
480-
481- $ serialized = $ this ->serialize (new UnionTypedProperties (false ));
482- self ::assertEquals (static ::getContent ('data_bool ' ), $ serialized );
483-
484- $ serialized = $ this ->serialize (new UnionTypedProperties ('foo ' ));
485- self ::assertEquals (static ::getContent ('data_string ' ), $ serialized );
468+ $ object = new UnionTypedProperties ($ data );
469+ self ::assertEquals ($ object , $ this ->deserialize (static ::getContent ($ expected ), UnionTypedProperties::class));
470+ self ::assertEquals ($ this ->serialize ($ object ), static ::getContent ($ expected ));
486471 }
487472
488473 public function testTrueDataType ()
0 commit comments