Skip to content

Commit

Permalink
fix: update serialized
Browse files Browse the repository at this point in the history
  • Loading branch information
Yozhef committed Aug 26, 2021
1 parent ba9646e commit 8554798
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Context/MessengerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 8554798

Please sign in to comment.