diff --git a/tests/Functional/Driver/Mysqli/ResultTest.php b/tests/Functional/Driver/Mysqli/ResultTest.php index 8b993fb2212..f216765a15d 100644 --- a/tests/Functional/Driver/Mysqli/ResultTest.php +++ b/tests/Functional/Driver/Mysqli/ResultTest.php @@ -6,9 +6,11 @@ use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError; use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError; +use Doctrine\DBAL\Driver\Mysqli\Result; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\TestUtil; +use mysqli_driver; /** @requires extension mysqli */ class ResultTest extends FunctionalTestCase @@ -16,6 +18,11 @@ class ResultTest extends FunctionalTestCase protected function setUp(): void { if (TestUtil::isDriverOneOf('mysqli')) { + $mysqliDriver = new mysqli_driver(); + $mysqliDriver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT; + + $this->connection->executeQuery('CREATE TABLE my_table (my_col_1 INT NOT NULL);'); + return; } @@ -29,14 +36,12 @@ protected function tearDown(): void public function testSuccessfulRowCountFromAffectedRows(): void { - var_dump($this->connection->getNativeConnection()->error); - var_dump($this->connection->getNativeConnection()->error_list); - var_dump($this->connection->getNativeConnection()->info); - self::assertSame(0, $this->connection->getNativeConnection()->affected_rows); + // var_dump($this->connection->getNativeConnection()->error); + // var_dump($this->connection->getNativeConnection()->error_list); + // var_dump($this->connection->getNativeConnection()->info); + // self::assertSame(0, $this->connection->getNativeConnection()->affected_rows); - $this->connection->executeQuery('CREATE TABLE my_table (my_col_1 INT NOT NULL);'); - - // self::assertSame(-1, $this->connection->getNativeConnection()->affected_rows); + self::assertSame(0, $this->connection->getNativeConnection()->affected_rows); $result = $this->connection->executeQuery('INSERT INTO my_table VALUES(7);'); @@ -46,12 +51,13 @@ public function testSuccessfulRowCountFromAffectedRows(): void public function testFailingRowCountFromAffectedRows(): void { - $result = $this->connection->executeQuery('CREATE TABLE my_table (my_col_1 INT NOT NULL);'); + $mysqliStmt = $this->connection->getNativeConnection() + ->prepare('INSERT INTO my_table VALUES(7);'); - self::assertSame(-1, $this->connection->getNativeConnection()->affected_rows); + self::assertSame(-1, $mysqliStmt->affected_rows); $this->expectException(ConnectionError::class); - $result->rowCount(); + (new Result($mysqliStmt))->rowCount(); } }