-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle cached result column names and rows separately
- Loading branch information
Showing
6 changed files
with
148 additions
and
132 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
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
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,97 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Cache; | ||
|
||
use Doctrine\DBAL\Cache\ArrayResult; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ArrayResultTest extends TestCase | ||
{ | ||
private ArrayResult $result; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->result = new ArrayResult(['username', 'active'], [ | ||
['jwage', true], | ||
['romanb', false], | ||
]); | ||
} | ||
|
||
public function testFree(): void | ||
{ | ||
self::assertSame(2, $this->result->rowCount()); | ||
|
||
$this->result->free(); | ||
|
||
self::assertSame(0, $this->result->rowCount()); | ||
} | ||
|
||
public function testColumnCount(): void | ||
{ | ||
self::assertSame(2, $this->result->columnCount()); | ||
} | ||
|
||
public function testColumnNames(): void | ||
{ | ||
self::assertSame('username', $this->result->getColumnName(0)); | ||
self::assertSame('active', $this->result->getColumnName(1)); | ||
} | ||
|
||
public function testRowCount(): void | ||
{ | ||
self::assertSame(2, $this->result->rowCount()); | ||
} | ||
|
||
public function testFetchAssociative(): void | ||
{ | ||
self::assertSame([ | ||
'username' => 'jwage', | ||
'active' => true, | ||
], $this->result->fetchAssociative()); | ||
} | ||
|
||
public function testFetchNumeric(): void | ||
{ | ||
self::assertSame(['jwage', true], $this->result->fetchNumeric()); | ||
} | ||
|
||
public function testFetchOne(): void | ||
{ | ||
self::assertSame('jwage', $this->result->fetchOne()); | ||
self::assertSame('romanb', $this->result->fetchOne()); | ||
} | ||
|
||
public function testFetchAllAssociative(): void | ||
{ | ||
self::assertSame([ | ||
[ | ||
'username' => 'jwage', | ||
'active' => true, | ||
], | ||
[ | ||
'username' => 'romanb', | ||
'active' => false, | ||
], | ||
], $this->result->fetchAllAssociative()); | ||
} | ||
|
||
public function testEmptyResult(): void | ||
{ | ||
$result = new ArrayResult(['a'], []); | ||
self::assertSame('a', $result->getColumnName(0)); | ||
} | ||
|
||
public function testSameColumnNames(): void | ||
{ | ||
$result = new ArrayResult(['a', 'a'], [[1, 2]]); | ||
|
||
self::assertSame('a', $result->getColumnName(0)); | ||
self::assertSame('a', $result->getColumnName(1)); | ||
|
||
self::assertEquals([1, 2], $result->fetchNumeric()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.