Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c377f73

Browse files
Nyholmderrabus
authored andcommitted
[Messenger] Fixed tests with doctrine 3
1 parent 006283d commit c377f73

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Driver\PDO\Exception;
1515
use Doctrine\DBAL\Driver\PDOException;
1616
use Doctrine\DBAL\Exception\DeadlockException;
17+
use Doctrine\DBAL\Version;
1718
use PHPUnit\Framework\TestCase;
1819
use Symfony\Component\Messenger\Envelope;
1920
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
@@ -77,7 +78,14 @@ public function testOccursRetryableExceptionFromConnection()
7778
$serializer = $this->createSerializer();
7879
$connection = $this->createMock(Connection::class);
7980
$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);
8189
$receiver = new DoctrineReceiver($connection, $serializer);
8290
$this->assertSame([], $receiver->get());
8391
$this->assertSame([], $receiver->get());

0 commit comments

Comments
 (0)