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')); |
|
|
|
|
88
|
|
|
self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); |
89
|
|
|
self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb')); |
|
|
|
|
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') |
|
|
|
|
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
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.