Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Serializer] Rewrite AbstractObjectNormalizer::createChildContext() to use the provided cache_key from original context #53523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changed assert approach for childContextCacheKey
  • Loading branch information
amne committed Jan 12, 2024
commit 72aac246a201030a4afec28300a5a96d7fe4f66e
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,8 @@ public function testChildContextKeepsOriginalContextCacheKey()
];

$normalizer = new class() extends AbstractObjectNormalizerDummy {
public ?string $childContextCacheKey = null;

protected function extractAttributes(object $object, string $format = null, array $context = []): array
{
return array_keys((array) $object);
Expand All @@ -814,15 +816,16 @@ protected function getAttributeValue(object $object, string $attribute, string $
protected function createChildContext(array $parentContext, string $attribute, ?string $format): array
{
$childContext = parent::createChildContext($parentContext, $attribute, $format);
AbstractObjectNormalizerTest::assertSame('hardcoded-'.$attribute, $childContext['cache_key']);
$this->childContextCacheKey = $childContext['cache_key'];

return $childContext;
}
};

$serializer = new Serializer([$normalizer]);
$normalizedObject = $serializer->normalize($foobar, null, ['cache_key' => 'hardcoded']);
$this->assertSame($data, $normalizedObject);
// $this->assertSame($data, $normalizedObject);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected comment I guess

$this->assertSame('hardcoded-foo', $normalizer->childContextCacheKey);
}

public function testDenormalizeUnionOfEnums()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.