|
16 | 16 | use PHPUnit\Framework\TestCase;
|
17 | 17 | use Symfony\Component\Messenger\Envelope;
|
18 | 18 | use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
|
| 19 | +use Symfony\Component\Messenger\Exception\TransportException; |
19 | 20 | use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
|
20 | 21 | use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
|
21 | 22 | use Symfony\Component\Messenger\Transport\Doctrine\Connection;
|
@@ -74,13 +75,32 @@ public function testOccursRetryableExceptionFromConnection()
|
74 | 75 | {
|
75 | 76 | $serializer = $this->createSerializer();
|
76 | 77 | $connection = $this->createMock(Connection::class);
|
| 78 | + $connection->method('getConfiguration')->willReturn([ |
| 79 | + 'redelivery_max_count' => 3 |
| 80 | + ]); |
77 | 81 | $driverException = new PDOException(new \PDOException('Deadlock', 40001));
|
78 | 82 | $connection->method('get')->willThrowException(new DeadlockException('Deadlock', $driverException));
|
79 | 83 | $receiver = new DoctrineReceiver($connection, $serializer);
|
80 | 84 | $actualEnvelopes = $receiver->get();
|
81 | 85 | $this->assertSame([], $actualEnvelopes);
|
82 | 86 | }
|
83 | 87 |
|
| 88 | + public function testOccursRetryableExceptionAfterMaxCountFromConnection() |
| 89 | + { |
| 90 | + $serializer = $this->createSerializer(); |
| 91 | + $connection = $this->createMock(Connection::class); |
| 92 | + $connection->method('getConfiguration')->willReturn([ |
| 93 | + 'redelivery_max_count' => 2 |
| 94 | + ]); |
| 95 | + $driverException = new PDOException(new \PDOException('Deadlock', 40001)); |
| 96 | + $connection->method('get')->willThrowException(new DeadlockException('Deadlock', $driverException)); |
| 97 | + $receiver = new DoctrineReceiver($connection, $serializer); |
| 98 | + $actualEnvelopes = $receiver->get(); |
| 99 | + $this->assertSame([], $actualEnvelopes); |
| 100 | + $this->expectException(TransportException::class); |
| 101 | + $receiver->get(); |
| 102 | + } |
| 103 | + |
84 | 104 | public function testAll()
|
85 | 105 | {
|
86 | 106 | $serializer = $this->createSerializer();
|
|
0 commit comments