diff --git a/tests/Unit/Database/Schema/BlueprintTest.php b/tests/Unit/Database/Schema/BlueprintTest.php index 0095c30..42a559a 100644 --- a/tests/Unit/Database/Schema/BlueprintTest.php +++ b/tests/Unit/Database/Schema/BlueprintTest.php @@ -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 { @@ -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 */ @@ -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());