[Messenger] Fixed tests with doctrine 3

This commit is contained in:
Nyholm 2020-11-01 19:04:36 +01:00 committed by Alexander M. Turek
parent 006283dd81
commit c377f73304
1 changed files with 9 additions and 1 deletions

View File

@ -14,6 +14,7 @@ namespace Symfony\Component\Messenger\Tests\Transport\Doctrine;
use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\DBAL\Driver\PDOException;
use Doctrine\DBAL\Exception\DeadlockException;
use Doctrine\DBAL\Version;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
@ -77,7 +78,14 @@ class DoctrineReceiverTest extends TestCase
$serializer = $this->createSerializer();
$connection = $this->createMock(Connection::class);
$driverException = class_exists(Exception::class) ? Exception::new(new \PDOException('Deadlock', 40001)) : new PDOException(new \PDOException('Deadlock', 40001));
$connection->method('get')->willThrowException(new DeadlockException('Deadlock', $driverException));
if (!class_exists(Version::class)) {
// This is doctrine/dbal 3.x
$deadlockException = new DeadlockException($driverException, null);
} else {
$deadlockException = new DeadlockException('Deadlock', $driverException);
}
$connection->method('get')->willThrowException($deadlockException);
$receiver = new DoctrineReceiver($connection, $serializer);
$this->assertSame([], $receiver->get());
$this->assertSame([], $receiver->get());