-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathSQLiteDialectTest.php
More file actions
70 lines (53 loc) · 2.36 KB
/
SQLiteDialectTest.php
File metadata and controls
70 lines (53 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace DBDiff\Tests\Unit;
use PHPUnit\Framework\TestCase;
use DBDiff\SQLGen\Dialect\SQLiteDialect;
class SQLiteDialectTest extends TestCase
{
private SQLiteDialect $dialect;
protected function setUp(): void
{
$this->dialect = new SQLiteDialect();
}
// ── Quoting (double-quote, same as Postgres via AbstractAnsi) ─────────
public function testQuoteSimpleName(): void
{
$this->assertSame('"products"', $this->dialect->quote('products'));
}
public function testQuoteNameWithDoubleQuote(): void
{
$this->assertSame('"col""name"', $this->dialect->quote('col"name'));
}
// ── Driver ────────────────────────────────────────────────────────────
public function testGetDriver(): void
{
$this->assertSame('sqlite', $this->dialect->getDriver());
}
public function testIsNotMySQLOnly(): void
{
$this->assertFalse($this->dialect->isMySQLOnly());
}
// ── DROP TRIGGER (no ON table for SQLite) ─────────────────────────────
public function testDropTriggerNoOnClause(): void
{
$sql = $this->dialect->dropTrigger('trg_audit', 'orders');
$this->assertSame('DROP TRIGGER IF EXISTS "trg_audit";', $sql);
}
// ── DROP INDEX (schema-level, same as Postgres) ───────────────────────
public function testDropIndexNoAlterTable(): void
{
$sql = $this->dialect->dropIndex('orders', 'idx_orders_user');
$this->assertSame('DROP INDEX "idx_orders_user";', $sql);
}
// ── ADD/DROP COLUMN ───────────────────────────────────────────────────
public function testAddColumn(): void
{
$sql = $this->dialect->addColumn('users', '"phone" TEXT DEFAULT NULL');
$this->assertSame('ALTER TABLE "users" ADD COLUMN "phone" TEXT DEFAULT NULL;', $sql);
}
public function testDropColumn(): void
{
$sql = $this->dialect->dropColumn('users', 'old_field');
$this->assertSame('ALTER TABLE "users" DROP COLUMN "old_field";', $sql);
}
}