From 95595fdebc076eda0d53e674e8e174e688fe3959 Mon Sep 17 00:00:00 2001 From: Pirmin Mattmann Date: Mon, 23 Dec 2024 21:08:07 +0100 Subject: [PATCH] insert test again testNormalizeDoesntReplaceWhenTargetEntityIsMissing --- .../RelatedCollectionLinkNormalizerTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/api/tests/Serializer/Normalizer/RelatedCollectionLinkNormalizerTest.php b/api/tests/Serializer/Normalizer/RelatedCollectionLinkNormalizerTest.php index bad2d7abd0..d7f8ff12df 100644 --- a/api/tests/Serializer/Normalizer/RelatedCollectionLinkNormalizerTest.php +++ b/api/tests/Serializer/Normalizer/RelatedCollectionLinkNormalizerTest.php @@ -325,6 +325,28 @@ public function testNormalizeDoesntReplaceWhenNoFilters() { $this->shouldNotReplaceChildren($result); } + public function testNormalizeDoesntReplaceWhenTargetEntityIsMissing() { + // given + $resource = new ParentEntity(); + $this->mockDecoratedNormalizer(); + $this->mockNameConverter(); + $this->mockAssociationMetadata(OneToManyAssociationMapping::fromMappingArray([ + 'targetEntity' => '', + 'mappedBy' => 'parent', + 'fieldName' => 'children', + 'sourceEntity' => ParentEntity::class, + ])); + $this->mockRelatedResourceMetadata(['filters' => ['attribute_filter_something_something']]); + $this->mockRelatedFilterDescription(['parent' => ['strategy' => 'exact']]); + $this->mockGeneratedRoute(); + + // when + $result = $this->normalizer->normalize($resource, null, ['resource_class' => ParentEntity::class]); + + // then + $this->shouldNotReplaceChildren($result); + } + public function testNormalizeDoesntReplaceWhenNotADoctrineAssociation() { // given $resource = new ParentEntity();