SqliteConnectionTest.php 1.55 KB
Newer Older
1 2 3
<?php
namespace yiiunit\framework\db\sqlite;

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

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

Alexander Makarov committed
14 15 16 17
	public function testConstruct()
	{
		$connection = $this->getConnection(false);
		$params = $this->database;
18

Alexander Makarov committed
19 20
		$this->assertEquals($params['dsn'], $connection->dsn);
	}
21

Alexander Makarov committed
22 23 24 25 26 27 28
	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"));
	}
29

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

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