Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Driver\Mysqli; | ||
|
||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Tests\TestUtil; | ||
|
||
/** @requires extension mysqli */ | ||
final class ResultTest extends FunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
if (TestUtil::isDriverOneOf('mysqli')) { | ||
$this->connection->executeQuery('CREATE TABLE my_table (my_col_1 INT NOT NULL);'); | ||
|
||
return; | ||
} | ||
|
||
self::markTestSkipped('This test requires the mysqli driver.'); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->connection->executeStatement('DROP TABLE IF EXISTS my_table;'); | ||
} | ||
|
||
public function testSuccessfulRowCountFromAffectedRows(): void | ||
{ | ||
self::assertSame(0, $this->connection->getNativeConnection()->affected_rows); | ||
|
||
$result = $this->connection->executeQuery('INSERT INTO my_table VALUES(7);'); | ||
|
||
self::assertSame(1, $this->connection->getNativeConnection()->affected_rows); | ||
self::assertSame(1, $result->rowCount()); | ||
} | ||
|
||
public function testFailingRowCountFromAffectedRows(): void | ||
{ | ||
self::assertSame(0, $this->connection->getNativeConnection()->affected_rows); | ||
|
||
// @todo: Find a query or a command sequence capable to reproduce the -1 result. | ||
$result = $this->connection->executeQuery('INSERT INTO my_table VALUES(7);'); | ||
|
||
self::assertSame(-1, $this->connection->getNativeConnection()->affected_rows); | ||
self::assertSame(-1, $result->rowCount()); | ||
} | ||
} |