Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDeadCode committed Jan 18, 2025
1 parent dce0432 commit 857d022
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ public function testAddingUniqueKey()
$this->assertSame('alter table "users" add constraint "bar" unique ("foo")', $statements[0]);
}

public function testAddingUniqueKeyViaUseCreateIndex()
{
$blueprint = new Blueprint('users');
$blueprint->unique('foo', 'bar')->useCreateIndex();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('create unique index "bar" on "users" ("foo")', $statements[0]);
}

public function testAddingIndex()
{
$blueprint = new Blueprint('users');
Expand Down Expand Up @@ -364,6 +374,26 @@ public function testAddingRawIndex()
$this->assertSame('create index "raw_index" on "users" ((function(column)))', $statements[0]);
}

public function testAddingRawUniqueKey()
{
$blueprint = new Blueprint('users');
$blueprint->rawUnique('foo,bar', 'baz');
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table "users" add constraint "baz" unique (foo,bar)', $statements[0]);
}

public function testAddingRawUniqueKeyViaUseCreateIndex()
{
$blueprint = new Blueprint('users');
$blueprint->rawUnique('function(column)', 'baz')->useCreateIndex();
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('create unique index "baz" on "users" (function(column))', $statements[0]);
}

public function testAddingIncrementingID()
{
$blueprint = new Blueprint('users');
Expand Down

0 comments on commit 857d022

Please sign in to comment.