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

Commit 801b9c8

Browse filesBrowse files
committed
improved test to showcase that normalizing two identical object structures with different contexts should not create two cache keys
1 parent a8edf81 commit 801b9c8
Copy full SHA for 801b9c8

File tree

1 file changed

+8
-5
lines changed
Filter options

1 file changed

+8
-5
lines changed

‎src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public function testChildContextKeepsOriginalContextCacheKey()
562562
];
563563

564564
$normalizer = new class() extends AbstractObjectNormalizerDummy {
565-
public ?string $childContextCacheKey = null;
565+
public $childContextCacheKey = null;
566566

567567
protected function extractAttributes(object $object, string $format = null, array $context = []): array
568568
{
@@ -584,14 +584,17 @@ protected function createChildContext(array $parentContext, string $attribute, ?
584584
};
585585

586586
$serializer = new Serializer([$normalizer]);
587-
$serializer->normalize($foobar, null, ['cache_key' => 'hardcoded']);
587+
$serializer->normalize($foobar, null, ['cache_key' => 'hardcoded', 'iri' => '/dummy/1']);
588+
$firstCacheKey = $normalizer->childContextCacheKey;
588589

589-
$this->assertSame('hardcoded-foo', $normalizer->childContextCacheKey);
590+
$serializer->normalize($foobar, null, ['cache_key' => 'hardcoded', 'iri' => '/dummy/2']);
591+
$secondCacheKey = $normalizer->childContextCacheKey;
592+
593+
$this->assertSame($firstCacheKey, $secondCacheKey);
590594
}
591595

592596
public function testChildContextCacheKeyStaysFalseWhenOriginalCacheKeyIsFalse()
593597
{
594-
xdebug_break();
595598
$foobar = new Dummy();
596599
$foobar->foo = new EmptyDummy();
597600
$foobar->bar = 'bar';
@@ -603,7 +606,7 @@ public function testChildContextCacheKeyStaysFalseWhenOriginalCacheKeyIsFalse()
603606
];
604607

605608
$normalizer = new class() extends AbstractObjectNormalizerDummy {
606-
public ?bool $childContextCacheKey = null;
609+
public $childContextCacheKey = null;
607610

608611
protected function extractAttributes(object $object, string $format = null, array $context = []): array
609612
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.