1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\DBAL\Platforms; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
8
|
|
|
use Doctrine\DBAL\Platforms\PostgreSQL94Platform; |
9
|
|
|
use Doctrine\DBAL\Schema\Table; |
10
|
|
|
use Doctrine\DBAL\Types\Types; |
11
|
|
|
use function assert; |
12
|
|
|
|
13
|
|
|
class PostgreSQL94PlatformTest extends AbstractPostgreSQLPlatformTestCase |
14
|
|
|
{ |
15
|
|
|
public function createPlatform() : AbstractPlatform |
16
|
|
|
{ |
17
|
|
|
return new PostgreSQL94Platform(); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function testSupportsPartialIndexes() : void |
21
|
|
|
{ |
22
|
|
|
self::assertTrue($this->platform->supportsPartialIndexes()); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testGetCreateTableSQLWithColumnCollation() : void |
26
|
|
|
{ |
27
|
|
|
$table = new Table('foo'); |
28
|
|
|
$table->addColumn('id', 'string'); |
29
|
|
|
$table->addOption('comment', 'foo'); |
30
|
|
|
self::assertSame( |
31
|
|
|
[ |
32
|
|
|
'CREATE TABLE foo (id VARCHAR NOT NULL)', |
33
|
|
|
"COMMENT ON TABLE foo IS 'foo'", |
34
|
|
|
], |
35
|
|
|
$this->platform->getCreateTableSQL($table), |
36
|
|
|
'Comments are added to table.' |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testColumnCollationDeclarationSQL() : void |
41
|
|
|
{ |
42
|
|
|
self::assertEquals( |
43
|
|
|
'COLLATE "en_US.UTF-8"', |
44
|
|
|
$this->platform->getColumnCollationDeclarationSQL('en_US.UTF-8') |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @group DBAL-553 |
50
|
|
|
*/ |
51
|
|
|
public function testHasNativeJsonType() : void |
52
|
|
|
{ |
53
|
|
|
self::assertTrue($this->platform->hasNativeJsonType()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @group DBAL-553 |
58
|
|
|
*/ |
59
|
|
|
public function testReturnsJsonTypeDeclarationSQL() : void |
60
|
|
|
{ |
61
|
|
|
self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); |
62
|
|
|
self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => false])); |
63
|
|
|
self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true])); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testReturnsSmallIntTypeDeclarationSQL() : void |
67
|
|
|
{ |
68
|
|
|
self::assertSame( |
69
|
|
|
'SMALLSERIAL', |
70
|
|
|
$this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true]) |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
self::assertSame( |
74
|
|
|
'SMALLINT', |
75
|
|
|
$this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => false]) |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
self::assertSame( |
79
|
|
|
'SMALLINT', |
80
|
|
|
$this->platform->getSmallIntTypeDeclarationSQL([]) |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @group DBAL-553 |
86
|
|
|
*/ |
87
|
|
|
public function testInitializesJsonTypeMapping() : void |
88
|
|
|
{ |
89
|
|
|
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); |
90
|
|
|
self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); |
91
|
|
|
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); |
92
|
|
|
self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('jsonb')); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @group DBAL-1220 |
97
|
|
|
*/ |
98
|
|
|
public function testReturnsCloseActiveDatabaseConnectionsSQL() : void |
99
|
|
|
{ |
100
|
|
|
assert($this->platform instanceof PostgreSQL94Platform); |
101
|
|
|
|
102
|
|
|
self::assertSame( |
103
|
|
|
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'", |
104
|
|
|
$this->platform->getCloseActiveDatabaseConnectionsSQL('foo') |
105
|
|
|
); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|