Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngine into kesills-php8-fetch-mode

The new test conflicted with another one being added. I accepted the incoming
changes, then just copy and pasted this branch's test above it.
  • Loading branch information
Kenneth-Sills committed Jun 27, 2024
2 parents 1309f7c + d781588 commit 3260c52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/FakePdoStatementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function fetch(
$cursor_orientation = \PDO::FETCH_ORI_NEXT,
$cursor_offset = 0
) {
if ($fetch_style === -123) {
if ($fetch_style === -123 || $fetch_style === \PDO::FETCH_DEFAULT) {
$fetch_style = $this->fetchMode;
}

Expand Down Expand Up @@ -415,7 +415,7 @@ public function fetchColumn($column = 0)
*/
public function universalFetchAll(int $fetch_style = -123, ...$args) : array
{
if ($fetch_style === -123) {
if ($fetch_style === -123 || $fetch_style === \PDO::FETCH_DEFAULT) {
$fetch_style = $this->fetchMode;
$fetch_argument = $this->fetchArgument;
$ctor_args = $this->fetchConstructorArgs;
Expand Down
22 changes: 22 additions & 0 deletions tests/EndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ public function testSelectWithDefaultFetchAssoc()
);
}

public function testSelectFetchDefault()
{
$pdo = self::getConnectionToFullDB();

$query = $pdo->prepare("SELECT id FROM `video_game_characters` WHERE `id` > :id ORDER BY `id` ASC");
$query->bindValue(':id', 14);
$query->execute();

$this->assertSame(
['id' => '15', 0 => '15'],
$query->fetch(\PDO::FETCH_DEFAULT)
);

$this->assertSame(
[
['id' => '15', 0 => '15'],
['id' => '16', 0 => '16']
],
$query->fetchAll(\PDO::FETCH_DEFAULT)
);
}

public function testSelectFetchAssoc()
{
$pdo = self::getConnectionToFullDB();
Expand Down

0 comments on commit 3260c52

Please sign in to comment.