Completed
Push — master ( 7f4ef4...16d449 )
by Sergei
34:13 queued 34:08
created

Tests/DBAL/Functional/PDOStatementTest.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\Functional;
6
7
use Doctrine\DBAL\Driver\Exception\UnknownFetchMode;
8
use Doctrine\DBAL\Driver\PDOConnection;
9
use Doctrine\DBAL\Schema\Table;
10
use Doctrine\Tests\DbalFunctionalTestCase;
11
use PDO;
12
13
/**
14
 * @requires extension pdo
15
 */
16
class PDOStatementTest extends DbalFunctionalTestCase
17
{
18
    protected function setUp() : void
19
    {
20
        parent::setUp();
21
22
        if (! $this->connection->getWrappedConnection() instanceof PDOConnection) {
23
            $this->markTestSkipped('PDO-only test');
24
        }
25
26
        $table = new Table('stmt_test');
27
        $table->addColumn('id', 'integer');
28
        $table->addColumn('name', 'string', ['length' => 8]);
29
        $this->connection->getSchemaManager()->dropAndCreateTable($table);
30
    }
31
32
    public function testPDOSpecificModeIsAccepted() : void
33
    {
34
        $this->connection->insert('stmt_test', [
35
            'id' => 1,
36
            'name' => 'Alice',
37
        ]);
38
        $this->connection->insert('stmt_test', [
39
            'id' => 2,
40
            'name' => 'Bob',
41
        ]);
42
43
        self::expectException(UnknownFetchMode::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        self::/** @scrutinizer ignore-call */ 
44
              expectException(UnknownFetchMode::class);
Loading history...
44
        self::expectExceptionMessage('Unknown fetch mode 12.');
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCa...xpectExceptionMessage() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        self::/** @scrutinizer ignore-call */ 
45
              expectExceptionMessage('Unknown fetch mode 12.');
Loading history...
45
46
        $data = $this->connection->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