8000 fix compatibility with Doctrine DBAL 3 · symfony/symfony@3e071bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e071bd

Browse files
committed
fix compatibility with Doctrine DBAL 3
1 parent 50f37f0 commit 3e071bd

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\DBAL\Abstraction\Result;
1515
use Doctrine\DBAL\DBALException;
16+
use Doctrine\DBAL\Exception;
1617
use Doctrine\DBAL\Platforms\AbstractPlatform;
1718
use Doctrine\DBAL\Query\QueryBuilder;
1819
use Doctrine\DBAL\Schema\AbstractSchemaManager;
@@ -87,7 +88,12 @@ public function testItThrowsATransportExceptionIfItCannotAcknowledgeMessage()
8788
{
8889
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
8990
$driverConnection = $this->getDBALConnectionMock();
90-
$driverConnection->method('delete')->willThrowException(new DBALException());
91+
92+
if (class_exists(Exception::class)) {
93+
$driverConnection->method('delete')->willThrowException(new Exception());
94+
} else {
95+
$driverConnection->method('delete')->willThrowException(new DBALException());
96+
}
9197

9298
$connection = new Connection([], $driverConnection);
9399
$connection->ack('dummy_id');
@@ -97,7 +103,12 @@ public function testItThrowsATransportExceptionIfItCannotRejectMessage()
97103
{
98104
$this->expectException('Symfony\Component\Messenger\Exception\TransportException');
99105
$driverConnection = $this->getDBALConnectionMock();
100-
$driverConnection->method('delete')->willThrowException(new DBALException());
106+
107+
if (class_exists(Exception::class)) {
108+
$driverConnection->method('delete')->willThrowException(new Exception());
109+
} else {
110+
$driverConnection->method('delete')->willThrowException(new DBALException());
111+
}
101112

102113
$connection = new Connection([], $driverConnection);
103114
$connection->reject('dummy_id');

src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Connection as DBALConnection;
1515
use Doctrine\DBAL\DBALException;
1616
use Doctrine\DBAL\Driver\Result;
17+
use Doctrine\DBAL\Exception;
1718
use Doctrine\DBAL\Exception\TableNotFoundException;
1819
use Doctrine\DBAL\Query\QueryBuilder;
1920
use Doctrine\DBAL\Schema\Comparator;
@@ -205,6 +206,8 @@ public function ack(string $id): bool
205206
{
206207
try {
207208
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
209+
} catch (Exception $exception) {
210+
throw new TransportException($exception->getMessage(), 0, $exception);
208211
} catch (DBALException $exception) {
209212
throw new TransportException($exception->getMessage(), 0, $exception);
210213
}
@@ -214,6 +217,8 @@ public function reject(string $id): bool
214217
{
215218
try {
216219
return $this->driverConnection->delete($this->configuration['table_name'], ['id' => $id]) > 0;
220+
} catch (Exception $exception) {
221+
throw new TransportException($exception->getMessage(), 0, $exception);
217222
} catch (DBALException $exception) {
218223
throw new TransportException($exception->getMessage(), 0, $exception);
219224
}

0 commit comments

Comments
 (0)
0