Skip to content

Commit 15f384c

Browse files
committed
minor #50735 [Serializer] Refactor tests to not extends ObjectNormalizer (lyrixx)
This PR was merged into the 6.3 branch. Discussion ---------- [Serializer] Refactor tests to not extends ObjectNormalizer | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | see #50660 (comment) Commits ------- 2269c3f [Serializer] Refactor tests to not extends ObjectNormalizer
2 parents 8199380 + 2269c3f commit 15f384c

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,27 @@ public function testNormalizeUsesContextAttributeForProperties()
724724

725725
$this->assertSame(['propertyWithoutNullSkipNullValues' => 'foo'], $data);
726726
}
727+
728+
public function testDefaultExcludeFromCacheKey()
729+
{
730+
$object = new DummyChild();
731+
$object->bar = 'not called';
732+
733+
$normalizer = new class(null, null, null, null, null, [AbstractObjectNormalizer::EXCLUDE_FROM_CACHE_KEY => ['foo']]) extends AbstractObjectNormalizerDummy {
734+
public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
735+
{
736+
AbstractObjectNormalizerTest::assertContains('foo', $this->defaultContext[ObjectNormalizer::EXCLUDE_FROM_CACHE_KEY]);
737+
$data->bar = 'called';
738+
739+
return true;
740+
}
741+
};
742+
743+
$serializer = new Serializer([$normalizer]);
744+
$serializer->normalize($object);
745+
746+
$this->assertSame('called', $object->bar);
747+
}
727748
}
728749

729750
class AbstractObjectNormalizerDummy extends AbstractObjectNormalizer

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -680,19 +680,6 @@ public function testNormalizeNotSerializableContext()
680680
}]));
681681
}
682682

683-
public function testDefaultExcludeFromCacheKey()
684-
{
685-
$normalizer = new class(null, null, null, null, null, null, [ObjectNormalizer::EXCLUDE_FROM_CACHE_KEY => ['foo']]) extends ObjectNormalizer {
686-
protected function isCircularReference($object, &$context): bool
687-
{
688-
ObjectNormalizerTest::assertContains('foo', $this->defaultContext[ObjectNormalizer::EXCLUDE_FROM_CACHE_KEY]);
689-
690-
return false;
691-
}
692-
};
693-
$normalizer->normalize(new ObjectDummy());
694-
}
695-
696683
public function testThrowUnexpectedValueException()
697684
{
698685
$this->expectException(UnexpectedValueException::class);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy