Skip to content

Commit 84f86d9

Browse files
committed
Simplify test by catch all exceptions
1 parent 2510198 commit 84f86d9

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Consumption/Extension/DoctrinePingConnectionExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Enqueue\Consumption\Context\MessageReceived;
99
use Enqueue\Consumption\MessageReceivedExtensionInterface;
1010
use ErrorException;
11+
use Throwable;
1112

1213
class DoctrinePingConnectionExtension implements MessageReceivedExtensionInterface
1314
{
@@ -58,7 +59,7 @@ private function ping(Connection $connection): bool
5859
$connection->executeQuery($dummySelectSQL);
5960

6061
return true;
61-
} catch (ErrorException | ConnectionLost $exception) {
62+
} catch (Throwable $exception) {
6263
return false;
6364
} finally {
6465
restore_error_handler();

Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace Enqueue\Bundle\Tests\Unit\Consumption\Extension;
44

55
use Doctrine\DBAL\Connection;
6-
use Doctrine\DBAL\Driver\DriverException;
7-
use Doctrine\DBAL\Exception\ConnectionLost;
86
use Doctrine\DBAL\Platforms\AbstractPlatform;
97
use Doctrine\Persistence\ManagerRegistry;
108
use Enqueue\Bundle\Consumption\Extension\DoctrinePingConnectionExtension;
@@ -79,14 +77,10 @@ public function testShouldDoesReconnectIfConnectionFailed()
7977
->willReturn(true)
8078
;
8179

82-
$exception = class_exists(DriverException::class)
83-
? new ConnectionLost('message', $this->createMock(DriverException::class))
84-
: new ConnectionLost($this->createMock(Doctrine\DBAL\Driver\Exception::class), null);
85-
8680
$connection
8781
->expects($this->once())
8882
->method('getDatabasePlatform')
89-
->willThrowException($exception)
83+
->willThrowException(new \Exception())
9084
;
9185
$connection
9286
->expects($this->once())

0 commit comments

Comments
 (0)