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

Skip to content

Commit 91fb5fa

Browse files
committed
minor #38947 [Messenger] Fixed tests with doctrine 3 (Nyholm)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Messenger] Fixed tests with doctrine 3 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Tests on 4.4 is failing with: >1) Symfony\Component\Messenger\Tests\Transport\Doctrine\DoctrineReceiverTest::testOccursRetryableExceptionFromConnection TypeError: Argument 1 passed to Doctrine\DBAL\Exception\DriverException::__construct() must implement interface Doctrine\DBAL\Driver\Exception, string given, called in /home/travis/build/symfony/symfony/src/Symfony/Component/Messenger/Tests/Transport/Doctrine/DoctrineReceiverTest.php on line 80 This will make sure the tests supports doctrine/dbal 3. Commits ------- c377f73 [Messenger] Fixed tests with doctrine 3
2 parents 006283d + c377f73 commit 91fb5fa

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)