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
fa1523ac
Commit
fa1523ac
authored
Dec 16, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-245: Require chunkSizeBytes to be a positive integer
parent
21f8624d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
0 deletions
+26
-0
Bucket.php
src/GridFS/Bucket.php
+4
-0
WritableStream.php
src/GridFS/WritableStream.php
+4
-0
BucketFunctionalTest.php
tests/GridFS/BucketFunctionalTest.php
+9
-0
WritableStreamFunctionalTest.php
tests/GridFS/WritableStreamFunctionalTest.php
+9
-0
No files found.
src/GridFS/Bucket.php
View file @
fa1523ac
...
...
@@ -80,6 +80,10 @@ class Bucket
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
$options
[
'chunkSizeBytes'
]
<
1
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Expected "chunkSizeBytes" option to be >= 1, %d given'
,
$options
[
'chunkSizeBytes'
]));
}
if
(
isset
(
$options
[
'readConcern'
])
&&
!
$options
[
'readConcern'
]
instanceof
ReadConcern
)
{
throw
InvalidArgumentException
::
invalidType
(
'"readConcern" option'
,
$options
[
'readConcern'
],
'MongoDB\Driver\ReadConcern'
);
}
...
...
src/GridFS/WritableStream.php
View file @
fa1523ac
...
...
@@ -67,6 +67,10 @@ class WritableStream
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
$options
[
'chunkSizeBytes'
]
<
1
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Expected "chunkSizeBytes" option to be >= 1, %d given'
,
$options
[
'chunkSizeBytes'
]));
}
if
(
isset
(
$options
[
'contentType'
])
&&
!
is_string
(
$options
[
'contentType'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"contentType" option'
,
$options
[
'contentType'
],
'string'
);
}
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
fa1523ac
...
...
@@ -68,6 +68,15 @@ class BucketFunctionalTest extends FunctionalTestCase
return
$options
;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage Expected "chunkSizeBytes" option to be >= 1, 0 given
*/
public
function
testConstructorShouldRequireChunkSizeBytesOptionToBePositive
()
{
new
Bucket
(
$this
->
manager
,
$this
->
getDatabaseName
(),
[
'chunkSizeBytes'
=>
0
]);
}
/**
* @dataProvider provideInputDataAndExpectedChunks
*/
...
...
tests/GridFS/WritableStreamFunctionalTest.php
View file @
fa1523ac
...
...
@@ -52,6 +52,15 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
return
$options
;
}
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @expectedExceptionMessage Expected "chunkSizeBytes" option to be >= 1, 0 given
*/
public
function
testConstructorShouldRequireChunkSizeBytesOptionToBePositive
()
{
new
WritableStream
(
$this
->
collectionWrapper
,
'filename'
,
[
'chunkSizeBytes'
=>
0
]);
}
/**
* @dataProvider provideInputDataAndExpectedMD5
*/
...
...
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