From 8554798d39ae6d0bd11735f4bf23073e03466f18 Mon Sep 17 00:00:00 2001 From: Yozhef Date: Thu, 26 Aug 2021 15:08:02 +0300 Subject: [PATCH] fix: update serialized --- src/Context/MessengerContext.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Context/MessengerContext.php b/src/Context/MessengerContext.php index fd2d290..6c08a45 100644 --- a/src/Context/MessengerContext.php +++ b/src/Context/MessengerContext.php @@ -10,21 +10,21 @@ use Exception; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Messenger\Transport\InMemoryTransport; -use Symfony\Component\Serializer\SerializerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizableInterface; class MessengerContext implements Context { use ArraySimilarTrait; private ContainerInterface $container; - private SerializerInterface $serializer; + private NormalizableInterface $normalizable; public function __construct( ContainerInterface $container, - SerializerInterface $serializer + NormalizableInterface $normalizable ) { $this->container = $container; - $this->serializer = $serializer; + $this->normalizable = $normalizable; } /** @@ -65,14 +65,11 @@ public function busShouldContainMessageWithJsonAndVariableFields( $expectedMessage = $this->decodeExpectedJson($expectedMessage); $transport = $this->getMessengerTransportByName($busName); - $actualMessageList = []; foreach ($transport->get() as $envelope) { $actualMessage = $this->convertToArray($envelope->getMessage()); if ($this->isArraysSimilar($actualMessage, $expectedMessage, $variableFields)) { return; } - - $actualMessageList[] = $actualMessage; } throw new Exception( @@ -167,7 +164,7 @@ private function getPrettyJson(array $message) */ private function convertToArray($object): array { - return (array) $this->serializer->normalize($object); + return (array) $this->normalizable->normalize($object); } /**