PostgreSQLConnectionTest.php 2.13 KB
Newer Older
1 2 3 4 5
<?php
namespace yiiunit\framework\db\pgsql;

use yiiunit\framework\db\ConnectionTest;

6 7 8 9
/**
 * @group db
 * @group pgsql
 */
Alexander Makarov committed
10 11
class PostgreSQLConnectionTest extends ConnectionTest
{
12
    protected $driverName = 'pgsql';
13

14 15 16 17
    public function testConnection()
    {
        $this->getConnection(true);
    }
18

19 20 21 22 23 24 25
    public function testQuoteValue()
    {
        $connection = $this->getConnection(false);
        $this->assertEquals(123, $connection->quoteValue(123));
        $this->assertEquals("'string'", $connection->quoteValue('string'));
        $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting"));
    }
Alexander Makarov committed
26

27 28 29 30 31 32 33 34 35 36 37
    public function testQuoteTableName()
    {
        $connection = $this->getConnection(false);
        $this->assertEquals('"table"', $connection->quoteTableName('table'));
        $this->assertEquals('"table"', $connection->quoteTableName('"table"'));
        $this->assertEquals('"schema"."table"', $connection->quoteTableName('schema.table'));
        $this->assertEquals('"schema"."table"', $connection->quoteTableName('schema."table"'));
        $this->assertEquals('"schema"."table"', $connection->quoteTableName('"schema"."table"'));
        $this->assertEquals('{{table}}', $connection->quoteTableName('{{table}}'));
        $this->assertEquals('(table)', $connection->quoteTableName('(table)'));
    }
Alexander Makarov committed
38

39 40 41 42 43 44 45 46 47 48 49 50
    public function testQuoteColumnName()
    {
        $connection = $this->getConnection(false);
        $this->assertEquals('"column"', $connection->quoteColumnName('column'));
        $this->assertEquals('"column"', $connection->quoteColumnName('"column"'));
        $this->assertEquals('"table"."column"', $connection->quoteColumnName('table.column'));
        $this->assertEquals('"table"."column"', $connection->quoteColumnName('table."column"'));
        $this->assertEquals('"table"."column"', $connection->quoteColumnName('"table"."column"'));
        $this->assertEquals('[[column]]', $connection->quoteColumnName('[[column]]'));
        $this->assertEquals('{{column}}', $connection->quoteColumnName('{{column}}'));
        $this->assertEquals('(column)', $connection->quoteColumnName('(column)'));
    }
51
}