PostgreSQLConnectionTest.php 1.96 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
{
Carsten Brandt committed
12
	protected $driverName = 'pgsql';
13

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

Alexander Makarov committed
19 20
	public function testQuoteValue()
	{
21 22 23 24 25
		$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

	public function testQuoteTableName()
28 29 30 31 32 33 34 35 36 37
	{
		$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

	public function testQuoteColumnName()
40 41 42 43 44 45 46 47 48 49 50
	{
		$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
}