Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 997adef

Browse files
author
Emmanuel BORGES
committed
GetSetMethodNormalizer correctly ignore the attributes specified in "ignored_attributes"
1 parent 52cfeb3 commit 997adef

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,25 @@ public function testLegacyUncallableCallbacks()
329329
$this->doTestUncallableCallbacks(true);
330330
}
331331

332+
public function testIgnoredAttributesInContext()
333+
{
334+
$ignoredAttributes = ['foo', 'bar', 'baz', 'object'];
335+
$this->createNormalizer([GetSetMethodNormalizer::IGNORED_ATTRIBUTES => $ignoredAttributes]);
336+
337+
$obj = new GetSetDummy();
338+
$obj->setFoo('foo');
339+
$obj->setBar('bar');
340+
$obj->setCamelCase(true);
341+
342+
$this->assertEquals(
343+
[
344+
'fooBar' => 'foobar',
345+
'camelCase' => true,
346+
],
347+
$this->normalizer->normalize($obj, 'any')
348+
);
349+
}
350+
332351
private function doTestUncallableCallbacks(bool $legacy = false)
333352
{
334353
$callbacks = ['bar' => null];

0 commit comments

Comments
 (0)