2
2
3
3
namespace MongoDB \Tests \GridFS ;
4
4
5
- use MongoDB \GridFS ;
5
+ use MongoDB \Driver \ReadPreference ;
6
+ use MongoDB \Driver \WriteConcern ;
7
+ use MongoDB \GridFS \Bucket ;
6
8
7
9
/**
8
10
* Functional tests for the Bucket class.
9
11
*/
10
12
class BucketFunctionalTest extends FunctionalTestCase
11
13
{
14
+ public function testValidConstructorOptions ()
15
+ {
16
+ new Bucket ($ this ->manager , $ this ->getDatabaseName (), [
17
+ 'bucketName ' => 'test ' ,
18
+ 'chunkSizeBytes ' => 8192 ,
19
+ 'readPreference ' => new ReadPreference (ReadPreference::RP_PRIMARY ),
20
+ 'writeConcern ' => new WriteConcern (WriteConcern::MAJORITY , 1000 ),
21
+ ]);
22
+ }
12
23
13
24
/**
14
25
* @expectedException MongoDB\Exception\InvalidArgumentException
15
26
* @dataProvider provideInvalidConstructorOptions
16
27
*/
17
28
public function testConstructorOptionTypeChecks (array $ options )
18
29
{
19
- new \ MongoDB \ GridFS \ Bucket ($ this ->manager , $ this ->getDatabaseName (), $ options );
30
+ new Bucket ($ this ->manager , $ this ->getDatabaseName (), $ options );
20
31
}
21
32
22
33
public function provideInvalidConstructorOptions ()
23
34
{
24
35
$ options = [];
25
- $ invalidBucketNames = [123 , 3.14 , true , [], new \stdClass ];
26
- $ invalidChunkSizes = ['foo ' , 3.14 , true , [], new \stdClass ];
27
36
37
+ foreach ($ this ->getInvalidStringValues () as $ value ) {
38
+ $ options [][] = ['bucketName ' => $ value ];
39
+ }
40
+
41
+ foreach ($ this ->getInvalidIntegerValues () as $ value ) {
42
+ $ options [][] = ['chunkSizeBytes ' => $ value ];
43
+ }
28
44
29
45
foreach ($ this ->getInvalidReadPreferenceValues () as $ value ) {
30
46
$ options [][] = ['readPreference ' => $ value ];
@@ -33,12 +49,6 @@ public function provideInvalidConstructorOptions()
33
49
foreach ($ this ->getInvalidWriteConcernValues () as $ value ) {
34
50
$ options [][] = ['writeConcern ' => $ value ];
35
51
}
36
- foreach ($ invalidBucketNames as $ value ) {
37
- $ options [][] = ['bucketName ' => $ value ];
38
- }
39
- foreach ($ invalidChunkSizes as $ value ) {
40
- $ options [][] = ['chunkSizeBytes ' => $ value ];
41
- }
42
52
43
53
return $ options ;
44
54
}
0 commit comments