From 09eafbc7ecc384210e54146b07421b37f7b3869a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 31 Oct 2020 23:33:43 +0100 Subject: [PATCH] Catch PDOException When using PDO, an exception is supposed to be thrown since we are using the error mode that behaves that way. It only seems to be the case since PHP 8 though. --- tests/Doctrine/Tests/DBAL/Functional/TransactionTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/TransactionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TransactionTest.php index 434bf37abe7..024feb8444f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TransactionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TransactionTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; +use PDOException; use function sleep; @@ -35,6 +36,12 @@ public function testCommitFalse(): void sleep(2); // during the sleep mysql will close the connection - $this->assertFalse(@$this->connection->commit()); // we will ignore `MySQL server has gone away` warnings + try { + $this->assertFalse(@$this->connection->commit()); // we will ignore `MySQL server has gone away` warnings + } catch (PDOException $e) { + /* For PDO, we are using ERRMODE EXCEPTION, so this catch should be + * necessary as the equivalent of the error control operator above. + * This seems to be the case only since PHP 8 */ + } } }