/
GrammarTest.php
46 lines (39 loc) · 1.34 KB
/
GrammarTest.php
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
<?php
declare(strict_types=1);
namespace Umbrellio\Postgres\Tests\Unit\Schema\Grammars;
use Mockery;
use Umbrellio\Postgres\PostgresConnection;
use Umbrellio\Postgres\Schema\Blueprint;
use Umbrellio\Postgres\Schema\Grammars\PostgresGrammar;
use Umbrellio\Postgres\Tests\TestCase;
class GrammarTest extends TestCase
{
/** @test */
public function addingGinIndex()
{
$blueprint = new Blueprint('test');
$blueprint->gin('foo');
$statements = $blueprint->toSql($this->getConnectionMock(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertStringContainsString('CREATE INDEX', $statements[0]);
$this->assertStringContainsString('GIN("foo")', $statements[0]);
}
/** @test */
public function addingGistIndex()
{
$blueprint = new Blueprint('test');
$blueprint->gist('foo');
$statements = $blueprint->toSql($this->getConnectionMock(), $this->getGrammar());
$this->assertCount(1, $statements);
$this->assertStringContainsString('CREATE INDEX', $statements[0]);
$this->assertStringContainsString('GIST("foo")', $statements[0]);
}
protected function getConnectionMock()
{
return Mockery::mock(PostgresConnection::class);
}
protected function getGrammar()
{
return new PostgresGrammar();
}
}