Skip to content

Commit 845ca16

Browse files
committed
Fix test
1 parent 0224a3a commit 845ca16

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/Functional/Driver/Mysqli/StatementTest.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
use Doctrine\DBAL\Tests\FunctionalTestCase;
1010
use Doctrine\DBAL\Tests\TestUtil;
1111
use Error;
12+
use ErrorException;
1213
use ReflectionProperty;
1314

15+
use function restore_error_handler;
16+
use function set_error_handler;
17+
1418
use const PHP_VERSION_ID;
1519

1620
/** @requires extension mysqli */
@@ -43,15 +47,22 @@ public function testStatementsAreDeallocatedProperly(): void
4347

4448
unset($statement, $driverStatement);
4549

46-
4750
if (PHP_VERSION_ID < 80000) {
48-
$this->expectError();
49-
$this->expectErrorMessage('mysqli_stmt::execute(): Couldn\'t fetch mysqli_stmt');
51+
$this->expectException(ErrorException::class);
52+
$this->expectExceptionMessage('mysqli_stmt::execute(): Couldn\'t fetch mysqli_stmt');
5053
} else {
5154
$this->expectException(Error::class);
5255
$this->expectExceptionMessage('mysqli_stmt object is already closed');
5356
}
5457

55-
$mysqliStatement->execute();
58+
set_error_handler(static function (int $errorNumber, string $error, string $file, int $line): void {
59+
throw new ErrorException($error, 0, $errorNumber, $file, $line);
60+
});
61+
62+
try {
63+
$mysqliStatement->execute();
64+
} finally {
65+
restore_error_handler();
66+
}
5667
}
5768
}

0 commit comments

Comments
 (0)