From 329402f847f764d4f4e74ebab40ad5b87d65b363 Mon Sep 17 00:00:00 2001 From: Stanislav Shupilkin Date: Mon, 18 Mar 2019 11:03:14 +0300 Subject: [PATCH] Add arg options for creating collections with options --- composer.json | 2 +- src/Jenssegers/Mongodb/Schema/Builder.php | 4 ++-- tests/SchemaTest.php | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index cdd4bff2b..36d14bf48 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "illuminate/container": "^5.8", "illuminate/database": "^5.8", "illuminate/events": "^5.8", - "mongodb/mongodb": "^1.0" + "mongodb/mongodb": "^1.4" }, "require-dev": { "phpunit/phpunit": "^6.0|^7.0", diff --git a/src/Jenssegers/Mongodb/Schema/Builder.php b/src/Jenssegers/Mongodb/Schema/Builder.php index 799fe8e80..0e352846d 100644 --- a/src/Jenssegers/Mongodb/Schema/Builder.php +++ b/src/Jenssegers/Mongodb/Schema/Builder.php @@ -85,11 +85,11 @@ public function table($collection, Closure $callback) /** * @inheritdoc */ - public function create($collection, Closure $callback = null) + public function create($collection, Closure $callback = null, array $options = []) { $blueprint = $this->createBlueprint($collection); - $blueprint->create(); + $blueprint->create($options); if ($callback) { $callback($blueprint); diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 5d63e28eb..b56cc639c 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -5,6 +5,7 @@ class SchemaTest extends TestCase public function tearDown(): void { Schema::drop('newcollection'); + Schema::drop('newcollection_two'); } public function testCreate() @@ -25,6 +26,13 @@ public function testCreateWithCallback() $this->assertTrue(Schema::hasCollection('newcollection')); } + public function testCreateWithOptions() + { + Schema::create('newcollection_two', null, ['capped' => true, 'size' => 1024]); + $this->assertTrue(Schema::hasCollection('newcollection_two')); + $this->assertTrue(Schema::hasTable('newcollection_two')); + } + public function testDrop() { Schema::create('newcollection');