@@ -626,6 +626,45 @@ public function testBadType()
626
626
$ normalizer ->denormalize (['foo ' => 42 ], Dummy::class);
627
627
}
628
628
629
+ public function testTypeChecksCanBeDisabled ()
630
+ {
631
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
632
+ $ propertyNameCollectionFactoryProphecy ->create (Dummy::class, [])->willReturn (
633
+ new PropertyNameCollection (['foo ' ])
634
+ )->shouldBeCalled ();
635
+
636
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
637
+ $ propertyMetadataFactoryProphecy ->create (Dummy::class, 'foo ' , [])->willReturn (
638
+ new PropertyMetadata (new Type (Type::BUILTIN_TYPE_FLOAT ), '' , false , true , false , false )
639
+ )->shouldBeCalled ();
640
+
641
+ $ iriConverterProphecy = $ this ->prophesize (IriConverterInterface::class);
642
+ $ propertyAccessorProphecy = $ this ->prophesize (PropertyAccessorInterface::class);
643
+ $ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
644
+
645
+ $ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
646
+ $ serializerProphecy ->willImplement (DenormalizerInterface::class);
647
+
648
+ $ normalizer = $ this ->getMockForAbstractClass (AbstractItemNormalizer::class, [
649
+ $ propertyNameCollectionFactoryProphecy ->reveal (),
650
+ $ propertyMetadataFactoryProphecy ->reveal (),
651
+ $ iriConverterProphecy ->reveal (),
652
+ $ resourceClassResolverProphecy ->reveal (),
653
+ $ propertyAccessorProphecy ->reveal (),
654
+ null ,
655
+ null ,
656
+ null ,
657
+ false ,
658
+ [],
659
+ [],
660
+ null ,
661
+ true ,
662
+ ]);
663
+ $ normalizer ->setSerializer ($ serializerProphecy ->reveal ());
664
+
665
+ $ normalizer ->denormalize (['foo ' => 42 ], Dummy::class, null , ['disable_type_enforcement ' => true ]);
666
+ }
667
+
629
668
public function testJsonAllowIntAsFloat ()
630
669
{
631
670
$ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
0 commit comments