Skip to content

Commit

Permalink
test: ensure that no statements are generated if there is no grammar …
Browse files Browse the repository at this point in the history
…defined
  • Loading branch information
MihailProcudin committed Mar 29, 2022
1 parent 4e211ff commit 64a8734
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion tests/Unit/Database/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,65 @@ public function setUp(): void
$this->blueprint = new Blueprint('indices');
}

/**
* @test
*/
public function it_fails_if_grammar_no_method()
{
$connection = m::mock(Connection::class);

$grammar = m::mock(ElasticsearchGrammar::class);

$grammar->shouldReceive('getFluentCommands')
->once()
->andReturn([]);

$fluent = $this->blueprint->dropUnique('test');

$this->blueprint->date('created_at');

$closure = function () {
};

$grammar->shouldReceive('compileDrop')
->never()
->with($this->blueprint, $fluent, $connection)
->andReturn($closure);

$results = $this->blueprint->toSql($connection, $grammar);

$this->assertEquals([], $results);
}

/**
* @test
*/
public function it_updates_mapping()
{
$connection = m::mock(Connection::class);

$grammar = m::mock(ElasticsearchGrammar::class);

$grammar->shouldReceive('getFluentCommands')
->once()
->andReturn([]);

$fluent = $this->blueprint->update();
$this->blueprint->date('created_at');

$closure = function () {
};

$grammar->shouldReceive('compileUpdate')
->once()
->with($this->blueprint, $fluent, $connection)
->andReturn($closure);

$results = $this->blueprint->toSql($connection, $grammar);

$this->assertEquals([$closure], $results);
}

/**
* @test
*/
Expand All @@ -36,7 +95,8 @@ public function it_creates_mapping()
$fluent = $this->blueprint->create();
$this->blueprint->date('created_at');

$closure = function () {};
$closure = function () {
};

$grammar->shouldReceive('compileCreate')
->once()
Expand Down

0 comments on commit 64a8734

Please sign in to comment.