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
bce6aa02
Commit
bce6aa02
authored
Apr 01, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #152
parents
bdda4858
a5ad8410
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
Bucket.php
src/GridFS/Bucket.php
+2
-0
BucketFunctionalTest.php
tests/GridFS/BucketFunctionalTest.php
+20
-10
No files found.
src/GridFS/Bucket.php
View file @
bce6aa02
...
...
@@ -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
;
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
bce6aa02
...
...
@@ -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
;
}
...
...
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