Skip to content

Commit c39542d

Browse files
committed
Test type checking for BulkWrite constructor options
1 parent 3bdebc4 commit c39542d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Operation/BulkWriteTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,33 @@ public function testUpdateOneUpsertOptionTypeCheck($upsert)
326326
array(BulkWrite::UPDATE_ONE => array(array('x' => 1), array('$set' => array('x' => 1)), array('upsert' => $upsert))),
327327
));
328328
}
329+
330+
/**
331+
* @expectedException MongoDB\Exception\InvalidArgumentTypeException
332+
* @dataProvider provideInvalidConstructorOptions
333+
*/
334+
public function testConstructorOptionTypeChecks(array $options)
335+
{
336+
new BulkWrite(
337+
$this->getDatabaseName(),
338+
$this->getCollectionName(),
339+
array(array(BulkWrite::INSERT_ONE => array(array('x' => 1)))),
340+
$options
341+
);
342+
}
343+
344+
public function provideInvalidConstructorOptions()
345+
{
346+
$options = array();
347+
348+
foreach ($this->getInvalidBooleanValues() as $value) {
349+
$options[][] = array('ordered' => $value);
350+
}
351+
352+
foreach ($this->getInvalidWriteConcernValues() as $value) {
353+
$options[][] = array('writeConcern' => $value);
354+
}
355+
356+
return $options;
357+
}
329358
}

0 commit comments

Comments
 (0)