Skip to content

Commit

Permalink
More debug
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Feb 10, 2023
1 parent 2312b10 commit 28ed740
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tests/Functional/Driver/Mysqli/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@

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
{
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;
}

Expand All @@ -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);');

Expand All @@ -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();
}
}

0 comments on commit 28ed740

Please sign in to comment.