|
14 | 14 | use Doctrine\DBAL\Driver\PDO\Exception; |
15 | 15 | use Doctrine\DBAL\Driver\PDOException; |
16 | 16 | use Doctrine\DBAL\Exception\DeadlockException; |
| 17 | +use Doctrine\DBAL\Version; |
17 | 18 | use PHPUnit\Framework\TestCase; |
18 | 19 | use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage; |
19 | 20 | use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection; |
@@ -77,7 +78,14 @@ public function testOccursRetryableExceptionFromConnection() |
77 | 78 | $serializer = $this->createSerializer(); |
78 | 79 | $connection = $this->createMock(Connection::class); |
79 | 80 | $driverException = class_exists(Exception::class) ? Exception::new(new \PDOException('Deadlock', 40001)) : new PDOException(new \PDOException('Deadlock', 40001)); |
80 | | - $connection->method('get')->willThrowException(new DeadlockException('Deadlock', $driverException)); |
| 81 | + if (!class_exists(Version::class)) { |
| 82 | + // This is doctrine/dbal 3.x |
| 83 | + $deadlockException = new DeadlockException($driverException, null); |
| 84 | + } else { |
| 85 | + $deadlockException = new DeadlockException('Deadlock', $driverException); |
| 86 | + } |
| 87 | + |
| 88 | + $connection->method('get')->willThrowException($deadlockException); |
81 | 89 | $receiver = new DoctrineReceiver($connection, $serializer); |
82 | 90 | $this->assertSame([], $receiver->get()); |
83 | 91 | $this->assertSame([], $receiver->get()); |
|
0 commit comments