Skip to content

Commit

Permalink
Add arg options for creating collections with options (mongodb#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
Smolevich authored and jenssegers committed Mar 20, 2019
1 parent a612c5f commit e998cd0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/Jenssegers/Mongodb/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SchemaTest extends TestCase
public function tearDown(): void
{
Schema::drop('newcollection');
Schema::drop('newcollection_two');
}

public function testCreate()
Expand All @@ -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');
Expand Down

0 comments on commit e998cd0

Please sign in to comment.