Skip to content

Commit

Permalink
[Serializer] Unset attributes when creating child context
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Dec 4, 2017
1 parent c9f72e2 commit 4ff9d99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -402,6 +402,8 @@ protected function createChildContext(array $parentContext, $attribute)
{
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
} else {
unset($parentContext[self::ATTRIBUTES]);
}

return $parentContext;
Expand Down
Expand Up @@ -673,6 +673,16 @@ public function testAttributesContextNormalize()
),
$serializer->normalize($objectDummy, null, $context)
);

$context = array('attributes' => array('foo', 'baz', 'object'));
$this->assertEquals(
array(
'foo' => 'foo',
'baz' => true,
'object' => array('foo' => 'innerFoo', 'bar' => 'innerBar'),
),
$serializer->normalize($objectDummy, null, $context)
);
}

public function testAttributesContextDenormalize()
Expand Down

0 comments on commit 4ff9d99

Please sign in to comment.