PostgreSQL91PlatformTest.php 1.35 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\Tests\DBAL\Platforms;

5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Platforms\PostgreSQL91Platform;
7
use Doctrine\DBAL\Schema\Table;
8

9
class PostgreSQL91PlatformTest extends PostgreSqlPlatformTest
10
{
11
    public function createPlatform() : AbstractPlatform
12 13 14 15
    {
        return new PostgreSQL91Platform();
    }

16
    public function testSupportsColumnCollation() : void
17
    {
Sergei Morozov's avatar
Sergei Morozov committed
18
        self::assertTrue($this->platform->supportsColumnCollation());
19 20 21 22 23
    }

    public function testColumnCollationDeclarationSQL() : void
    {
        self::assertSame(
24
            'COLLATE "en_US.UTF-8"',
Sergei Morozov's avatar
Sergei Morozov committed
25
            $this->platform->getColumnCollationDeclarationSQL('en_US.UTF-8')
26 27
        );
    }
28 29 30 31 32 33 34 35 36

    public function testGetCreateTableSQLWithColumnCollation() : void
    {
        $table = new Table('foo');
        $table->addColumn('no_collation', 'string');
        $table->addColumn('column_collation', 'string')->setPlatformOption('collation', 'en_US.UTF-8');

        self::assertSame(
            ['CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE "en_US.UTF-8")'],
Sergei Morozov's avatar
Sergei Morozov committed
37
            $this->platform->getCreateTableSQL($table),
38 39 40
            'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
        );
    }
41
}