Skip to content

Commit

Permalink
Catch PDOException
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greg0ire committed Oct 31, 2020
1 parent 1906c5f commit 09eafbc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/Doctrine/Tests/DBAL/Functional/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\Tests\DbalFunctionalTestCase;
use PDOException;

use function sleep;

Expand Down Expand Up @@ -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 */
}
}
}

0 comments on commit 09eafbc

Please sign in to comment.