Completed
Push — master ( eb09c9...d4a96d )
by Michael
46:33 queued 43:04
created

PDOStatementTest::setUp()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 4
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional;
4
5
use Doctrine\DBAL\Driver\PDOConnection;
6
use Doctrine\DBAL\Schema\Table;
7
use Doctrine\Tests\DbalFunctionalTestCase;
8
use PDO;
9
use function extension_loaded;
10
11
class PDOStatementTest extends DbalFunctionalTestCase
12
{
13
    protected function setUp()
14
    {
15
        if (! extension_loaded('pdo')) {
16
            $this->markTestSkipped('PDO is not installed');
17
        }
18
19
        parent::setUp();
20
21
        if (! $this->_conn->getWrappedConnection() instanceof PDOConnection) {
22
            $this->markTestSkipped('PDO-only test');
23
        }
24
25
        $table = new Table('stmt_test');
26
        $table->addColumn('id', 'integer');
27
        $table->addColumn('name', 'text');
28
        $this->_conn->getSchemaManager()->dropAndCreateTable($table);
29
    }
30
31
    /**
32
     * @group legacy
33
     * @expectedDeprecation Using a PDO fetch mode or their combination (%d given) is deprecated and will cause an error in Doctrine 3.0
34
     */
35
    public function testPDOSpecificModeIsAccepted()
36
    {
37
        $this->_conn->insert('stmt_test', [
38
            'id' => 1,
39
            'name' => 'Alice',
40
        ]);
41
        $this->_conn->insert('stmt_test', [
42
            'id' => 2,
43
            'name' => 'Bob',
44
        ]);
45
46
        $data = $this->_conn->query('SELECT id, name FROM stmt_test ORDER BY id')
47
            ->fetchAll(PDO::FETCH_KEY_PAIR);
48
49
        self::assertSame([
50
            1 => 'Alice',
51
            2 => 'Bob',
52
        ], $data);
53
    }
54
}
55