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
48712c21
Commit
48712c21
authored
Dec 05, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #301
parents
b4338692
471baea1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
Bucket.php
src/GridFS/Bucket.php
+2
-2
BucketFunctionalTest.php
tests/GridFS/BucketFunctionalTest.php
+20
-5
No files found.
src/GridFS/Bucket.php
View file @
48712c21
...
...
@@ -529,8 +529,8 @@ class Bucket
$metadata
=
stream_get_meta_data
(
$stream
);
if
(
!
$metadata
[
'wrapper_data'
]
instanceof
StreamWrapper
)
{
throw
InvalidArgumentException
::
invalidType
(
'$stream wrapper data'
,
$metadata
[
'wrapper_data'
]
,
'MongoDB\Driver\GridFS\StreamWrapper'
);
if
(
!
isset
(
$metadata
[
'wrapper_data'
])
||
!
$metadata
[
'wrapper_data'
]
instanceof
StreamWrapper
)
{
throw
InvalidArgumentException
::
invalidType
(
'$stream wrapper data'
,
isset
(
$metadata
[
'wrapper_data'
])
?
$metadata
[
'wrapper_data'
]
:
null
,
'MongoDB\Driver\GridFS\StreamWrapper'
);
}
return
$metadata
[
'wrapper_data'
]
->
getFile
();
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
48712c21
...
...
@@ -194,7 +194,7 @@ class BucketFunctionalTest extends FunctionalTestCase
public
function
provideInvalidStreamValues
()
{
return
$this
->
wrapValuesForDataProvider
(
[
null
,
123
,
'foo'
,
[],
hash_init
(
'md5'
)]
);
return
$this
->
wrapValuesForDataProvider
(
$this
->
getInvalidStreamValues
()
);
}
/**
...
...
@@ -407,13 +407,18 @@ class BucketFunctionalTest extends FunctionalTestCase
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidStreamValues
* @dataProvider provideInvalid
GridFS
StreamValues
*/
public
function
testGetFileDocumentForStreamShouldRequireStreamResource
(
$stream
)
public
function
testGetFileDocumentForStreamShouldRequire
GridFS
StreamResource
(
$stream
)
{
$this
->
bucket
->
getFileDocumentForStream
(
$stream
);
}
public
function
provideInvalidGridFSStreamValues
()
{
return
$this
->
wrapValuesForDataProvider
(
array_merge
(
$this
->
getInvalidStreamValues
(),
[
$this
->
createStream
()]));
}
public
function
testGetFileIdForStreamUsesTypeMap
()
{
$stream
=
$this
->
bucket
->
openUploadStream
(
'filename'
,
[
'_id'
=>
[
'x'
=>
1
]]);
...
...
@@ -441,9 +446,9 @@ class BucketFunctionalTest extends FunctionalTestCase
/**
* @expectedException MongoDB\Exception\InvalidArgumentException
* @dataProvider provideInvalidStreamValues
* @dataProvider provideInvalid
GridFS
StreamValues
*/
public
function
testGetFileIdForStreamShouldRequireStreamResource
(
$stream
)
public
function
testGetFileIdForStreamShouldRequire
GridFS
StreamResource
(
$stream
)
{
$this
->
bucket
->
getFileIdForStream
(
$stream
);
}
...
...
@@ -714,4 +719,14 @@ class BucketFunctionalTest extends FunctionalTestCase
call_user_func
(
$callback
,
$foundIndex
);
}
}
/**
* Return a list of invalid stream values.
*
* @return array
*/
private
function
getInvalidStreamValues
()
{
return
[
null
,
123
,
'foo'
,
[],
hash_init
(
'md5'
)];
}
}
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