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