|
18 | 18 | use Symfony\Component\Messenger\Stamp\ErrorDetailsStamp;
|
19 | 19 | use Symfony\Component\Messenger\Transport\Serialization\Normalizer\FlattenExceptionNormalizer;
|
20 | 20 | use Symfony\Component\Messenger\Transport\Serialization\Serializer;
|
| 21 | +use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor; |
| 22 | +use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; |
21 | 23 | use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
22 | 24 | use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
|
23 | 25 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
@@ -70,4 +72,26 @@ public function testDeserialization()
|
70 | 72 | $this->assertInstanceOf(ErrorDetailsStamp::class, $deserializedStamp);
|
71 | 73 | $this->assertEquals($stamp, $deserializedStamp);
|
72 | 74 | }
|
| 75 | + |
| 76 | + public function testDeserializationWithStringExceptionCode() |
| 77 | + { |
| 78 | + $exception = new StringErrorCodeException('exception message', 'some code'); |
| 79 | + $stamp = ErrorDetailsStamp::create($exception); |
| 80 | + $extractor = new ConstructorExtractor([ |
| 81 | + new ReflectionExtractor(), |
| 82 | + ]); |
| 83 | + $serializer = new Serializer( |
| 84 | + new SymfonySerializer([ |
| 85 | + new ArrayDenormalizer(), |
| 86 | + new FlattenExceptionNormalizer(), |
| 87 | + new ObjectNormalizer(null, null, null, $extractor, null, null, []), |
| 88 | + ], [new JsonEncoder()]) |
| 89 | + ); |
| 90 | + |
| 91 | + $deserializedEnvelope = $serializer->decode($serializer->encode(new Envelope(new \stdClass(), [$stamp]))); |
| 92 | + |
| 93 | + $deserializedStamp = $deserializedEnvelope->last(ErrorDetailsStamp::class); |
| 94 | + $this->assertInstanceOf(ErrorDetailsStamp::class, $deserializedStamp); |
| 95 | + $this->assertEquals($stamp, $deserializedStamp); |
| 96 | + } |
73 | 97 | }
|
0 commit comments