Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
2e9b3268
Commit
2e9b3268
authored
Jun 30, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #197
parents
42b3ad4a
823ed577
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
Bucket.php
src/GridFS/Bucket.php
+8
-1
BucketFunctionalTest.php
tests/GridFS/BucketFunctionalTest.php
+6
-0
No files found.
src/GridFS/Bucket.php
View file @
2e9b3268
...
@@ -5,6 +5,7 @@ namespace MongoDB\GridFS;
...
@@ -5,6 +5,7 @@ namespace MongoDB\GridFS;
use
MongoDB\BSON\ObjectId
;
use
MongoDB\BSON\ObjectId
;
use
MongoDB\Driver\Cursor
;
use
MongoDB\Driver\Cursor
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Exception\InvalidArgumentException
;
use
MongoDB\Exception\InvalidArgumentException
;
...
@@ -38,6 +39,8 @@ class Bucket
...
@@ -38,6 +39,8 @@ class Bucket
* * chunkSizeBytes (integer): The chunk size in bytes. Defaults to
* * chunkSizeBytes (integer): The chunk size in bytes. Defaults to
* 261120 (i.e. 255 KiB).
* 261120 (i.e. 255 KiB).
*
*
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
*
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
* * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
...
@@ -62,6 +65,10 @@ class Bucket
...
@@ -62,6 +65,10 @@ class Bucket
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
if
(
isset
(
$options
[
'readPreference'
])
&&
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
'MongoDB\Driver\ReadPreference'
);
}
}
...
@@ -73,7 +80,7 @@ class Bucket
...
@@ -73,7 +80,7 @@ class Bucket
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
databaseName
=
(
string
)
$databaseName
;
$this
->
options
=
$options
;
$this
->
options
=
$options
;
$collectionOptions
=
array_intersect_key
(
$options
,
[
'readPreference'
=>
1
,
'writeConcern'
=>
1
]);
$collectionOptions
=
array_intersect_key
(
$options
,
[
'read
Concern'
=>
1
,
'read
Preference'
=>
1
,
'writeConcern'
=>
1
]);
$this
->
collectionWrapper
=
new
CollectionWrapper
(
$manager
,
$databaseName
,
$options
[
'bucketName'
],
$collectionOptions
);
$this
->
collectionWrapper
=
new
CollectionWrapper
(
$manager
,
$databaseName
,
$options
[
'bucketName'
],
$collectionOptions
);
$this
->
registerStreamWrapper
();
$this
->
registerStreamWrapper
();
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
2e9b3268
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
MongoDB\Tests\GridFS
;
namespace
MongoDB\Tests\GridFS
;
use
MongoDB\BSON\Binary
;
use
MongoDB\BSON\Binary
;
use
MongoDB\Driver\ReadConcern
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\GridFS\Bucket
;
use
MongoDB\GridFS\Bucket
;
...
@@ -21,6 +22,7 @@ class BucketFunctionalTest extends FunctionalTestCase
...
@@ -21,6 +22,7 @@ class BucketFunctionalTest extends FunctionalTestCase
new
Bucket
(
$this
->
manager
,
$this
->
getDatabaseName
(),
[
new
Bucket
(
$this
->
manager
,
$this
->
getDatabaseName
(),
[
'bucketName'
=>
'test'
,
'bucketName'
=>
'test'
,
'chunkSizeBytes'
=>
8192
,
'chunkSizeBytes'
=>
8192
,
'readConcern'
=>
new
ReadConcern
(
ReadConcern
::
LOCAL
),
'readPreference'
=>
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
'readPreference'
=>
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
'writeConcern'
=>
new
WriteConcern
(
WriteConcern
::
MAJORITY
,
1000
),
'writeConcern'
=>
new
WriteConcern
(
WriteConcern
::
MAJORITY
,
1000
),
]);
]);
...
@@ -47,6 +49,10 @@ class BucketFunctionalTest extends FunctionalTestCase
...
@@ -47,6 +49,10 @@ class BucketFunctionalTest extends FunctionalTestCase
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidReadConcernValues
()
as
$value
)
{
$options
[][]
=
[
'readConcern'
=>
$value
];
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
$options
[][]
=
[
'readPreference'
=>
$value
];
$options
[][]
=
[
'readPreference'
=>
$value
];
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment