1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
/**
* @requires extension pdo
*/
class PDOStatementTest extends DbalFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
if (! $this->connection->getWrappedConnection() instanceof PDOConnection) {
$this->markTestSkipped('PDO-only test');
}
$table = new Table('stmt_test');
$table->addColumn('id', 'integer');
$table->addColumn('name', 'string');
$this->connection->getSchemaManager()->dropAndCreateTable($table);
}
public function testPDOSpecificModeIsAccepted(): void
{
$this->connection->insert('stmt_test', [
'id' => 1,
'name' => 'Alice',
]);
$this->connection->insert('stmt_test', [
'id' => 2,
'name' => 'Bob',
]);
$data = $this->connection->query('SELECT id, name FROM stmt_test ORDER BY id')
->fetchAll(PDO::FETCH_KEY_PAIR);
self::assertSame([
1 => 'Alice',
2 => 'Bob',
], $data);
}
}