Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Jan 16, 2025
1 parent 0224a3a commit 845ca16
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/Functional/Driver/Mysqli/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
use Error;
use ErrorException;
use ReflectionProperty;

use function restore_error_handler;
use function set_error_handler;

use const PHP_VERSION_ID;

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

unset($statement, $driverStatement);


if (PHP_VERSION_ID < 80000) {
$this->expectError();
$this->expectErrorMessage('mysqli_stmt::execute(): Couldn\'t fetch mysqli_stmt');
$this->expectException(ErrorException::class);
$this->expectExceptionMessage('mysqli_stmt::execute(): Couldn\'t fetch mysqli_stmt');
} else {
$this->expectException(Error::class);
$this->expectExceptionMessage('mysqli_stmt object is already closed');
}

$mysqliStatement->execute();
set_error_handler(static function (int $errorNumber, string $error, string $file, int $line): void {
throw new ErrorException($error, 0, $errorNumber, $file, $line);
});

try {
$mysqliStatement->execute();
} finally {
restore_error_handler();
}
}
}

0 comments on commit 845ca16

Please sign in to comment.