Skip to content

Commit 3f0609c

Browse files
committed
Add arg options for creating collections with options (mongodb#1734)
1 parent 8622051 commit 3f0609c

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"illuminate/container": "^5.8",
1616
"illuminate/database": "^5.8",
1717
"illuminate/events": "^5.8",
18-
"mongodb/mongodb": "^1.0"
18+
"mongodb/mongodb": "^1.4"
1919
},
2020
"require-dev": {
2121
"phpunit/phpunit": "^6.0|^7.0",

src/Jenssegers/Mongodb/Schema/Builder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ public function table($collection, Closure $callback)
8585
/**
8686
* @inheritdoc
8787
*/
88-
public function create($collection, Closure $callback = null)
88+
public function create($collection, Closure $callback = null, array $options = [])
8989
{
9090
$blueprint = $this->createBlueprint($collection);
9191

92-
$blueprint->create();
92+
$blueprint->create($options);
9393

9494
if ($callback) {
9595
$callback($blueprint);

tests/SchemaTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class SchemaTest extends TestCase
55
public function tearDown(): void
66
{
77
Schema::drop('newcollection');
8+
Schema::drop('newcollection_two');
89
}
910

1011
public function testCreate()
@@ -25,6 +26,13 @@ public function testCreateWithCallback()
2526
$this->assertTrue(Schema::hasCollection('newcollection'));
2627
}
2728

29+
public function testCreateWithOptions()
30+
{
31+
Schema::create('newcollection_two', null, ['capped' => true, 'size' => 1024]);
32+
$this->assertTrue(Schema::hasCollection('newcollection_two'));
33+
$this->assertTrue(Schema::hasTable('newcollection_two'));
34+
}
35+
2836
public function testDrop()
2937
{
3038
Schema::create('newcollection');

0 commit comments

Comments
 (0)