Skip to content

Commit

Permalink
Merge pull request #10 from zumba/avoid-insert-empty
Browse files Browse the repository at this point in the history
Avoiding issues when the fixture is empty
  • Loading branch information
cjsaylor authored Feb 17, 2017
2 parents 4e99268 + 0c37b11 commit 7862bf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion examples/PizzaTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class PizzaTraitTest extends \PHPUnit_Framework_TestCase {
'orders' => [
['size' => 'large', 'toppings' => ['cheese', 'ham']],
['size' => 'medium', 'toppings' => ['cheese']]
]
],
'carts' => [
// Intentionally empty
],
];

/**
Expand Down
4 changes: 3 additions & 1 deletion src/DataSet/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function dropAllCollections() {
*/
public function buildCollections() {
foreach ($this->fixture as $collection => $data) {
$this->connection->collection($collection)->insertMany($data);
if (!empty($data)) {
$this->connection->collection($collection)->insertMany($data);
}
}
return $this;
}
Expand Down

0 comments on commit 7862bf1

Please sign in to comment.