|
31 | 31 | use PHPUnit\Framework\TestCase;
|
32 | 32 | use Prophecy\Argument;
|
33 | 33 | use Prophecy\PhpUnit\ProphecyTrait;
|
34 |
| -use Symfony\Component\PropertyInfo\Type; |
35 | 34 | use Symfony\Component\Serializer\Exception\LogicException;
|
36 | 35 | use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
|
37 | 36 | use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
|
41 | 40 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
42 | 41 | use Symfony\Component\Serializer\Serializer;
|
43 | 42 | use Symfony\Component\Serializer\SerializerInterface;
|
| 43 | +use Symfony\Component\TypeInfo\Type; |
44 | 44 |
|
45 | 45 | /**
|
46 | 46 | * @author Kévin Dunglas <dunglas@gmail.com>
|
@@ -119,10 +119,10 @@ public function testNormalize(): void
|
119 | 119 |
|
120 | 120 | $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
|
121 | 121 | $propertyMetadataFactoryProphecy->create(Dummy::class, 'name', [])->willReturn(
|
122 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('')->withReadable(true) |
| 122 | + (new ApiProperty())->withNativeType(Type::string())->withDescription('')->withReadable(true) |
123 | 123 | );
|
124 | 124 | $propertyMetadataFactoryProphecy->create(Dummy::class, 'relatedDummy', [])->willReturn(
|
125 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, RelatedDummy::class)])->withDescription('')->withReadable(true)->withWritable(false)->withWritableLink(false) |
| 125 | + (new ApiProperty())->withNativeType(Type::object(RelatedDummy::class))->withDescription('')->withReadable(true)->withWritable(false)->withWritableLink(false) |
126 | 126 | );
|
127 | 127 |
|
128 | 128 | $iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
|
@@ -183,16 +183,10 @@ public function testNormalizeWithUnionIntersectTypes(): void
|
183 | 183 |
|
184 | 184 | $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
|
185 | 185 | $propertyMetadataFactoryProphecy->create(Book::class, 'author', [])->willReturn(
|
186 |
| - (new ApiProperty())->withBuiltinTypes([ |
187 |
| - new Type(Type::BUILTIN_TYPE_OBJECT, false, ActivableInterface::class), |
188 |
| - new Type(Type::BUILTIN_TYPE_OBJECT, false, TimestampableInterface::class), |
189 |
| - ])->withReadable(true) |
| 186 | + (new ApiProperty())->withNativeType(Type::intersection(Type::object(ActivableInterface::class), Type::object(TimestampableInterface::class)))->withReadable(true) |
190 | 187 | );
|
191 | 188 | $propertyMetadataFactoryProphecy->create(Book::class, 'library', [])->willReturn(
|
192 |
| - (new ApiProperty())->withBuiltinTypes([ |
193 |
| - new Type(Type::BUILTIN_TYPE_OBJECT, false, ActivableInterface::class), |
194 |
| - new Type(Type::BUILTIN_TYPE_OBJECT, false, TimestampableInterface::class), |
195 |
| - ])->withReadable(true) |
| 189 | + (new ApiProperty())->withNativeType(Type::intersection(Type::object(ActivableInterface::class), Type::object(TimestampableInterface::class)))->withReadable(true) |
196 | 190 | );
|
197 | 191 |
|
198 | 192 | $iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
|
@@ -247,10 +241,10 @@ public function testNormalizeWithoutCache(): void
|
247 | 241 |
|
248 | 242 | $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
|
249 | 243 | $propertyMetadataFactoryProphecy->create(Dummy::class, 'name', [])->willReturn(
|
250 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('')->withReadable(true) |
| 244 | + (new ApiProperty())->withNativeType(Type::string())->withDescription('')->withReadable(true) |
251 | 245 | );
|
252 | 246 | $propertyMetadataFactoryProphecy->create(Dummy::class, 'relatedDummy', [])->willReturn(
|
253 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, RelatedDummy::class)])->withDescription('')->withReadable(true)->withWritable(false)->withReadableLink(false) |
| 247 | + (new ApiProperty())->withNativeType(Type::object(RelatedDummy::class))->withDescription('')->withReadable(true)->withWritable(false)->withReadableLink(false) |
254 | 248 | );
|
255 | 249 |
|
256 | 250 | $iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
|
@@ -325,13 +319,13 @@ public function testMaxDepth(): void
|
325 | 319 |
|
326 | 320 | $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
|
327 | 321 | $propertyMetadataFactoryProphecy->create(MaxDepthDummy::class, 'id', [])->willReturn(
|
328 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_INT)])->withDescription('')->withReadable(true) |
| 322 | + (new ApiProperty())->withNativeType(Type::int())->withDescription('')->withReadable(true) |
329 | 323 | );
|
330 | 324 | $propertyMetadataFactoryProphecy->create(MaxDepthDummy::class, 'name', [])->willReturn(
|
331 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('')->withReadable(true) |
| 325 | + (new ApiProperty())->withNativeType(Type::string())->withDescription('')->withReadable(true) |
332 | 326 | );
|
333 | 327 | $propertyMetadataFactoryProphecy->create(MaxDepthDummy::class, 'child', [])->willReturn(
|
334 |
| - (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, MaxDepthDummy::class)])->withDescription('')->withReadable(true)->withWritable(false)->withReadableLink(true) |
| 328 | + (new ApiProperty())->withNativeType(Type::object(MaxDepthDummy::class))->withDescription('')->withReadable(true)->withWritable(false)->withReadableLink(true) |
335 | 329 | );
|
336 | 330 |
|
337 | 331 | $iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
|
|
0 commit comments