From 997adef2a26fe0f9f4998a7763e1d615d9f8209d Mon Sep 17 00:00:00 2001 From: Emmanuel BORGES Date: Thu, 7 Mar 2019 09:40:46 +0100 Subject: [PATCH] GetSetMethodNormalizer correctly ignore the attributes specified in "ignored_attributes" --- .../Normalizer/GetSetMethodNormalizerTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 37948bef4719..babb30a79ccf 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -329,6 +329,25 @@ public function testLegacyUncallableCallbacks() $this->doTestUncallableCallbacks(true); } + public function testIgnoredAttributesInContext() + { + $ignoredAttributes = ['foo', 'bar', 'baz', 'object']; + $this->createNormalizer([GetSetMethodNormalizer::IGNORED_ATTRIBUTES => $ignoredAttributes]); + + $obj = new GetSetDummy(); + $obj->setFoo('foo'); + $obj->setBar('bar'); + $obj->setCamelCase(true); + + $this->assertEquals( + [ + 'fooBar' => 'foobar', + 'camelCase' => true, + ], + $this->normalizer->normalize($obj, 'any') + ); + } + private function doTestUncallableCallbacks(bool $legacy = false) { $callbacks = ['bar' => null];