Skip to content

Commit

Permalink
test: blueprint testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailProcudin committed Mar 28, 2022
1 parent aebe758 commit 4e211ff
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions tests/Unit/Database/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
namespace Tests\Unit\Database\Schema;

use Carbon\Carbon;
use DesignMyNight\Elasticsearch\Connection;
use DesignMyNight\Elasticsearch\Database\Schema\Blueprint;
use DesignMyNight\Elasticsearch\Database\Schema\Grammars\ElasticsearchGrammar;
use Mockery as m;
use Tests\TestCase;

class BlueprintTest extends TestCase
{
/** @var Blueprint */
private $blueprint;
private Blueprint $blueprint;

public function setUp(): void
{
Expand All @@ -18,6 +20,34 @@ public function setUp(): void
$this->blueprint = new Blueprint('indices');
}

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

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

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

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

$closure = function () {};

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

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

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

/**
* @test
*/
Expand Down Expand Up @@ -72,8 +102,6 @@ public function it_adds_string()
*/
public function it_routing_required()
{
$type = 'routingRequired';

$this->blueprint->routingRequired();

$this->assertEquals(["_routing" => ["required" => true]], $this->blueprint->getMeta());
Expand Down

0 comments on commit 4e211ff

Please sign in to comment.