From af85fba7461ffff57a3b6b7449c9c1694cf49a07 Mon Sep 17 00:00:00 2001 From: Nicolas Valverde <64469669+n-valverde@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:35:01 +0200 Subject: [PATCH] fix(serializer): Remove ItemNormalizer wrong return type --- src/Elasticsearch/Serializer/ItemNormalizer.php | 2 +- tests/Elasticsearch/Serializer/ItemNormalizerTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Elasticsearch/Serializer/ItemNormalizer.php b/src/Elasticsearch/Serializer/ItemNormalizer.php index cad183402f3..9b49a40ab73 100644 --- a/src/Elasticsearch/Serializer/ItemNormalizer.php +++ b/src/Elasticsearch/Serializer/ItemNormalizer.php @@ -84,7 +84,7 @@ public function supportsDenormalization($data, $type, $format = null, array $con /** * {@inheritdoc} */ - public function normalize($object, $format = null, array $context = []): array + public function normalize($object, $format = null, array $context = []) { return $this->decorated->normalize($object, $format, $context); } diff --git a/tests/Elasticsearch/Serializer/ItemNormalizerTest.php b/tests/Elasticsearch/Serializer/ItemNormalizerTest.php index 57982f8f8b2..d4d8429c652 100644 --- a/tests/Elasticsearch/Serializer/ItemNormalizerTest.php +++ b/tests/Elasticsearch/Serializer/ItemNormalizerTest.php @@ -83,6 +83,13 @@ public function testNormalize(): void self::assertSame(['foo'], $this->itemNormalizer->normalize($object, 'json', ['groups' => 'foo'])); } + public function testNormalizeToString(): void + { + $this->normalizerProphecy->normalize($object = (object) ['foo'], 'json', ['groups' => 'foo'])->willReturn('/foo/iri')->shouldBeCalledOnce(); + + self::assertSame('/foo/iri', $this->itemNormalizer->normalize($object, 'json', ['groups' => 'foo'])); + } + public function testSupportsNormalization(): void { $this->normalizerProphecy->supportsNormalization($object = (object) ['foo'], 'json')->willReturn(true)->shouldBeCalledOnce();