Skip to content

Commit

Permalink
Fix getSetMethodNormalizer to correctly ignore the attributes specifi…
Browse files Browse the repository at this point in the history
…ed in "ignored_attributes"
  • Loading branch information
Emmanuel BORGES committed Mar 27, 2019
1 parent 860884a commit 606d8d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -109,7 +109,7 @@ protected function extractAttributes($object, $format = null, array $context = [

$attributeName = lcfirst(substr($method->name, 0 === strpos($method->name, 'is') ? 2 : 3));

if ($this->isAllowedAttribute($object, $attributeName)) {
if ($this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[] = $attributeName;
}
}
Expand Down
Expand Up @@ -91,6 +91,23 @@ public function testDenormalize()
$this->assertTrue($obj->isBaz());
}

public function testIgnoredAttributesInContext()
{
$ignoredAttributes = ['foo', 'bar', 'baz', 'object'];
$this->normalizer->setIgnoredAttributes($ignoredAttributes);
$obj = new GetSetDummy();
$obj->setFoo('foo');
$obj->setBar('bar');
$obj->setCamelCase(true);
$this->assertEquals(
[
'fooBar' => 'foobar',
'camelCase' => true,
],
$this->normalizer->normalize($obj, 'any')
);
}

public function testDenormalizeWithObject()
{
$data = new \stdClass();
Expand Down

0 comments on commit 606d8d3

Please sign in to comment.