MssqlConnectionTest.php 1.71 KB
Newer Older
resurtm committed
1 2 3 4
<?php

namespace yiiunit\framework\db\mssql;

Alexander Makarov committed
5 6
use yiiunit\framework\db\ConnectionTest;

7 8 9 10
/**
 * @group db
 * @group mssql
 */
Alexander Makarov committed
11
class MssqlConnectionTest extends ConnectionTest
resurtm committed
12
{
Carsten Brandt committed
13
	protected $driverName = 'sqlsrv';
resurtm committed
14

Alexander Makarov committed
15
	public function testQuoteValue()
resurtm committed
16 17 18 19 20 21 22
	{
		$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
23
	public function testQuoteTableName()
resurtm committed
24 25 26 27 28 29 30 31 32 33
	{
		$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('{{table}}', $connection->quoteTableName('{{table}}'));
		$this->assertEquals('(table)', $connection->quoteTableName('(table)'));
	}

Alexander Makarov committed
34
	public function testQuoteColumnName()
resurtm committed
35 36 37 38 39 40 41 42 43 44 45
	{
		$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('[[column]]', $connection->quoteColumnName('[[column]]'));
		$this->assertEquals('{{column}}', $connection->quoteColumnName('{{column}}'));
		$this->assertEquals('(column)', $connection->quoteColumnName('(column)'));
	}
}