Commit bce6aa02 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #152

parents bdda4858 a5ad8410
......@@ -5,6 +5,8 @@ namespace MongoDB\GridFS;
use MongoDB\BSON\ObjectId;
use MongoDB\Driver\Cursor;
use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\GridFSFileNotFoundException;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Operation\Find;
......
......@@ -2,13 +2,24 @@
namespace MongoDB\Tests\GridFS;
use MongoDB\GridFS;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern;
use MongoDB\GridFS\Bucket;
/**
* Functional tests for the Bucket class.
*/
class BucketFunctionalTest extends FunctionalTestCase
{
public function testValidConstructorOptions()
{
new Bucket($this->manager, $this->getDatabaseName(), [
'bucketName' => 'test',
'chunkSizeBytes' => 8192,
'readPreference' => new ReadPreference(ReadPreference::RP_PRIMARY),
'writeConcern' => new WriteConcern(WriteConcern::MAJORITY, 1000),
]);
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
......@@ -16,15 +27,20 @@ class BucketFunctionalTest extends FunctionalTestCase
*/
public function testConstructorOptionTypeChecks(array $options)
{
new \MongoDB\GridFS\Bucket($this->manager, $this->getDatabaseName(), $options);
new Bucket($this->manager, $this->getDatabaseName(), $options);
}
public function provideInvalidConstructorOptions()
{
$options = [];
$invalidBucketNames = [123, 3.14, true, [], new \stdClass];
$invalidChunkSizes = ['foo', 3.14, true, [], new \stdClass];
foreach ($this->getInvalidStringValues() as $value) {
$options[][] = ['bucketName' => $value];
}
foreach ($this->getInvalidIntegerValues() as $value) {
$options[][] = ['chunkSizeBytes' => $value];
}
foreach ($this->getInvalidReadPreferenceValues() as $value) {
$options[][] = ['readPreference' => $value];
......@@ -33,12 +49,6 @@ class BucketFunctionalTest extends FunctionalTestCase
foreach ($this->getInvalidWriteConcernValues() as $value) {
$options[][] = ['writeConcern' => $value];
}
foreach ($invalidBucketNames as $value) {
$options[][] = ['bucketName' => $value];
}
foreach ($invalidChunkSizes as $value) {
$options[][] = ['chunkSizeBytes' => $value];
}
return $options;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment