Failed Conditions
Push — 3.0.x ( f82f5c...40cc9b )
by Grégoire
24s queued 15s
created

PostgreSQL94PlatformTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
eloc 34
dl 0
loc 90
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A testSupportsPartialIndexes() 0 3 1
A testReturnsCloseActiveDatabaseConnectionsSQL() 0 5 1
A testReturnsJsonTypeDeclarationSQL() 0 5 1
A testColumnCollationDeclarationSQL() 0 5 1
A testInitializesJsonTypeMapping() 0 6 1
A testHasNativeJsonType() 0 3 1
A testReturnsSmallIntTypeDeclarationSQL() 0 15 1
A createPlatform() 0 3 1
A testGetCreateTableSQLWithColumnCollation() 0 12 1
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Platforms;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
7
use Doctrine\DBAL\Schema\Table;
8
use Doctrine\DBAL\Types\Type;
9
10
class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase
11
{
12
    public function createPlatform() : AbstractPlatform
13
    {
14
        return new PostgreSQL94Platform();
15
    }
16
17
    public function testSupportsPartialIndexes() : void
18
    {
19
        self::assertTrue($this->platform->supportsPartialIndexes());
20
    }
21
22
    public function testGetCreateTableSQLWithColumnCollation() : void
23
    {
24
        $table = new Table('foo');
25
        $table->addColumn('id', 'string');
26
        $table->addOption('comment', 'foo');
27
        self::assertSame(
28
            [
29
                'CREATE TABLE foo (id VARCHAR(255) NOT NULL)',
30
                "COMMENT ON TABLE foo IS 'foo'",
31
            ],
32
            $this->platform->getCreateTableSQL($table),
33
            'Comments are added to table.'
34
        );
35
    }
36
37
    public function testColumnCollationDeclarationSQL() : void
38
    {
39
        self::assertEquals(
40
            'COLLATE "en_US.UTF-8"',
41
            $this->platform->getColumnCollationDeclarationSQL('en_US.UTF-8')
42
        );
43
    }
44
45
    /**
46
     * @group DBAL-553
47
     */
48
    public function testHasNativeJsonType() : void
49
    {
50
        self::assertTrue($this->platform->hasNativeJsonType());
51
    }
52
53
    /**
54
     * @group DBAL-553
55
     */
56
    public function testReturnsJsonTypeDeclarationSQL() : void
57
    {
58
        self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([]));
59
        self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => false]));
60
        self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true]));
61
    }
62
63
    public function testReturnsSmallIntTypeDeclarationSQL() : void
64
    {
65
        self::assertSame(
66
            'SMALLSERIAL',
67
            $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true])
68
        );
69
70
        self::assertSame(
71
            'SMALLINT',
72
            $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => false])
73
        );
74
75
        self::assertSame(
76
            'SMALLINT',
77
            $this->platform->getSmallIntTypeDeclarationSQL([])
78
        );
79
    }
80
81
    /**
82
     * @group DBAL-553
83
     */
84
    public function testInitializesJsonTypeMapping() : void
85
    {
86
        self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json'));
87
        self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('json'));
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::JSON has been deprecated: Use {@see Types::JSON} instead. ( Ignorable by Annotation )

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

87
        self::assertEquals(/** @scrutinizer ignore-deprecated */ Type::JSON, $this->platform->getDoctrineTypeMapping('json'));

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
88
        self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb'));
89
        self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb'));
0 ignored issues
show
Deprecated Code introduced by
The constant Doctrine\DBAL\Types\Type::JSON has been deprecated: Use {@see Types::JSON} instead. ( Ignorable by Annotation )

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

89
        self::assertEquals(/** @scrutinizer ignore-deprecated */ Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb'));

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
90
    }
91
92
    /**
93
     * @group DBAL-1220
94
     */
95
    public function testReturnsCloseActiveDatabaseConnectionsSQL() : void
96
    {
97
        self::assertSame(
98
            "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'",
99
            $this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
0 ignored issues
show
Bug introduced by
The method getCloseActiveDatabaseConnectionsSQL() does not exist on Doctrine\DBAL\Platforms\AbstractPlatform. It seems like you code against a sub-type of Doctrine\DBAL\Platforms\AbstractPlatform such as Doctrine\DBAL\Platforms\PostgreSQL94Platform. ( Ignorable by Annotation )

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

99
            $this->platform->/** @scrutinizer ignore-call */ 
100
                             getCloseActiveDatabaseConnectionsSQL('foo')
Loading history...
100
        );
101
    }
102
}
103