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
9480f994
Unverified
Commit
9480f994
authored
Nov 15, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #696
parents
98fcbeab
86ff7317
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
69 additions
and
46 deletions
+69
-46
Client.php
src/Client.php
+1
-1
Bucket.php
src/GridFS/Bucket.php
+4
-4
WritableStream.php
src/GridFS/WritableStream.php
+3
-3
Watch.php
src/Operation/Watch.php
+5
-1
ClientTest.php
tests/ClientTest.php
+1
-1
BucketFunctionalTest.php
tests/GridFS/BucketFunctionalTest.php
+3
-3
WritableStreamFunctionalTest.php
tests/GridFS/WritableStreamFunctionalTest.php
+2
-2
AggregateTest.php
tests/Operation/AggregateTest.php
+2
-2
BulkWriteTest.php
tests/Operation/BulkWriteTest.php
+1
-1
FindAndModifyTest.php
tests/Operation/FindAndModifyTest.php
+3
-3
FindOneAndReplaceTest.php
tests/Operation/FindOneAndReplaceTest.php
+1
-1
FindOneAndUpdateTest.php
tests/Operation/FindOneAndUpdateTest.php
+1
-1
InsertManyTest.php
tests/Operation/InsertManyTest.php
+1
-1
UpdateTest.php
tests/Operation/UpdateTest.php
+2
-2
WatchTest.php
tests/Operation/WatchTest.php
+2
-2
TestCase.php
tests/TestCase.php
+37
-18
No files found.
src/Client.php
View file @
9480f994
...
...
@@ -95,7 +95,7 @@ class Client
{
$driverOptions
+=
[
'typeMap'
=>
self
::
$defaultTypeMap
];
if
(
isset
(
$driverOptions
[
'typeMap'
])
&&
!
is_array
(
$driverOptions
[
'typeMap'
]))
{
if
(
!
is_array
(
$driverOptions
[
'typeMap'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"typeMap" driver option'
,
$driverOptions
[
'typeMap'
],
'array'
);
}
...
...
src/GridFS/Bucket.php
View file @
9480f994
...
...
@@ -143,19 +143,19 @@ class Bucket
'disableMD5'
=>
false
,
];
if
(
isset
(
$options
[
'bucketName'
])
&&
!
is_string
(
$options
[
'bucketName'
]))
{
if
(
!
is_string
(
$options
[
'bucketName'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"bucketName" option'
,
$options
[
'bucketName'
],
'string'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
if
(
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
$options
[
'chunkSizeBytes'
]
<
1
)
{
if
(
$options
[
'chunkSizeBytes'
]
<
1
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Expected "chunkSizeBytes" option to be >= 1, %d given'
,
$options
[
'chunkSizeBytes'
]));
}
if
(
isset
(
$options
[
'disableMD5'
])
&&
!
is_bool
(
$options
[
'disableMD5'
]))
{
if
(
!
is_bool
(
$options
[
'disableMD5'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"disableMD5" option'
,
$options
[
'disableMD5'
],
'boolean'
);
}
...
...
src/GridFS/WritableStream.php
View file @
9480f994
...
...
@@ -114,15 +114,15 @@ class WritableStream
throw
InvalidArgumentException
::
invalidType
(
'"aliases" option'
,
$options
[
'aliases'
],
'array of strings'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
if
(
!
is_integer
(
$options
[
'chunkSizeBytes'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"chunkSizeBytes" option'
,
$options
[
'chunkSizeBytes'
],
'integer'
);
}
if
(
isset
(
$options
[
'chunkSizeBytes'
])
&&
$options
[
'chunkSizeBytes'
]
<
1
)
{
if
(
$options
[
'chunkSizeBytes'
]
<
1
)
{
throw
new
InvalidArgumentException
(
sprintf
(
'Expected "chunkSizeBytes" option to be >= 1, %d given'
,
$options
[
'chunkSizeBytes'
]));
}
if
(
isset
(
$options
[
'disableMD5'
])
&&
!
is_bool
(
$options
[
'disableMD5'
]))
{
if
(
!
is_bool
(
$options
[
'disableMD5'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"disableMD5" option'
,
$options
[
'disableMD5'
],
'boolean'
);
}
...
...
src/Operation/Watch.php
View file @
9480f994
...
...
@@ -178,10 +178,14 @@ class Watch implements Executable, /* @internal */ CommandSubscriber
'readPreference'
=>
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
];
if
(
isset
(
$options
[
'fullDocument'
])
&&
!
is_string
(
$options
[
'fullDocument'
]))
{
if
(
!
is_string
(
$options
[
'fullDocument'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"fullDocument" option'
,
$options
[
'fullDocument'
],
'string'
);
}
if
(
!
$options
[
'readPreference'
]
instanceof
ReadPreference
)
{
throw
InvalidArgumentException
::
invalidType
(
'"readPreference" option'
,
$options
[
'readPreference'
],
ReadPreference
::
class
);
}
if
(
isset
(
$options
[
'resumeAfter'
])
&&
!
is_array
(
$options
[
'resumeAfter'
])
&&
!
is_object
(
$options
[
'resumeAfter'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"resumeAfter" option'
,
$options
[
'resumeAfter'
],
'array or object'
);
}
...
...
tests/ClientTest.php
View file @
9480f994
...
...
@@ -33,7 +33,7 @@ class ClientTest extends TestCase
{
$options
=
[];
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidArrayValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
}
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
9480f994
...
...
@@ -62,15 +62,15 @@ class BucketFunctionalTest extends FunctionalTestCase
{
$options
=
[];
foreach
(
$this
->
getInvalidStringValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidStringValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'bucketName'
=>
$value
];
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'disableMD5'
=>
$value
];
}
...
...
tests/GridFS/WritableStreamFunctionalTest.php
View file @
9480f994
...
...
@@ -50,11 +50,11 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
{
$options
=
[];
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'disableMD5'
=>
$value
];
}
...
...
tests/Operation/AggregateTest.php
View file @
9480f994
...
...
@@ -27,7 +27,7 @@ class AggregateTest extends TestCase
{
$options
=
[];
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'allowDiskUse'
=>
$value
];
}
...
...
@@ -79,7 +79,7 @@ class AggregateTest extends TestCase
$options
[][]
=
[
'typeMap'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'useCursor'
=>
$value
];
}
...
...
tests/Operation/BulkWriteTest.php
View file @
9480f994
...
...
@@ -412,7 +412,7 @@ class BulkWriteTest extends TestCase
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'ordered'
=>
$value
];
}
...
...
tests/Operation/FindAndModifyTest.php
View file @
9480f994
...
...
@@ -40,7 +40,7 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'new'
=>
$value
];
}
...
...
@@ -48,7 +48,7 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'query'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'remove'
=>
$value
];
}
...
...
@@ -68,7 +68,7 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'update'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'upsert'
=>
$value
];
}
...
...
tests/Operation/FindOneAndReplaceTest.php
View file @
9480f994
...
...
@@ -49,7 +49,7 @@ class FindOneAndReplaceTest extends TestCase
$options
[][]
=
[
'projection'
=>
$value
];
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'returnDocument'
=>
$value
];
}
...
...
tests/Operation/FindOneAndUpdateTest.php
View file @
9480f994
...
...
@@ -49,7 +49,7 @@ class FindOneAndUpdateTest extends TestCase
$options
[][]
=
[
'projection'
=>
$value
];
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'returnDocument'
=>
$value
];
}
...
...
tests/Operation/InsertManyTest.php
View file @
9480f994
...
...
@@ -48,7 +48,7 @@ class InsertManyTest extends TestCase
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'ordered'
=>
$value
];
}
...
...
tests/Operation/UpdateTest.php
View file @
9480f994
...
...
@@ -52,7 +52,7 @@ class UpdateTest extends TestCase
$options
[][]
=
[
'collation'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'multi'
=>
$value
];
}
...
...
@@ -60,7 +60,7 @@ class UpdateTest extends TestCase
$options
[][]
=
[
'session'
=>
$value
];
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'upsert'
=>
$value
];
}
...
...
tests/Operation/WatchTest.php
View file @
9480f994
...
...
@@ -52,7 +52,7 @@ class WatchTest extends FunctionalTestCase
$options
[][]
=
[
'collation'
=>
$value
];
}
foreach
(
$this
->
getInvalidStringValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidStringValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'fullDocument'
=>
$value
];
}
...
...
@@ -64,7 +64,7 @@ class WatchTest extends FunctionalTestCase
$options
[][]
=
[
'readConcern'
=>
$value
];
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'readPreference'
=>
$value
];
}
...
...
tests/TestCase.php
View file @
9480f994
...
...
@@ -14,6 +14,7 @@ use ReflectionClass;
use
stdClass
;
use
Traversable
;
use
function
array_map
;
use
function
array_merge
;
use
function
array_values
;
use
function
call_user_func
;
use
function
getenv
;
...
...
@@ -165,91 +166,109 @@ abstract class TestCase extends BaseTestCase
/**
* Return a list of invalid array values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidArrayValues
()
protected
function
getInvalidArrayValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
true
,
new
stdClass
()]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
true
,
new
stdClass
()],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid boolean values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidBooleanValues
()
protected
function
getInvalidBooleanValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
[],
new
stdClass
()]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
[],
new
stdClass
()],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid document values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidDocumentValues
()
protected
function
getInvalidDocumentValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
true
]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
true
],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid integer values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidIntegerValues
()
protected
function
getInvalidIntegerValues
(
$includeNull
=
false
)
{
return
[
3.14
,
'foo'
,
true
,
[],
new
stdClass
()]
;
return
array_merge
([
3.14
,
'foo'
,
true
,
[],
new
stdClass
()],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid ReadPreference values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidReadConcernValues
()
protected
function
getInvalidReadConcernValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
new
WriteConcern
(
1
)]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
new
WriteConcern
(
1
)],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid ReadPreference values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidReadPreferenceValues
()
protected
function
getInvalidReadPreferenceValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadConcern
(),
new
WriteConcern
(
1
)]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadConcern
(),
new
WriteConcern
(
1
)],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid Session values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidSessionValues
()
protected
function
getInvalidSessionValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadConcern
(),
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
new
WriteConcern
(
1
)]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadConcern
(),
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
),
new
WriteConcern
(
1
)],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid string values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidStringValues
()
protected
function
getInvalidStringValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
true
,
[],
new
stdClass
()]
;
return
array_merge
([
123
,
3.14
,
true
,
[],
new
stdClass
()],
$includeNull
?
[
null
]
:
[])
;
}
/**
* Return a list of invalid WriteConcern values.
*
* @param boolean $includeNull
*
* @return array
*/
protected
function
getInvalidWriteConcernValues
()
protected
function
getInvalidWriteConcernValues
(
$includeNull
=
false
)
{
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadConcern
(),
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
)]
;
return
array_merge
([
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
(),
new
ReadConcern
(),
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
)],
$includeNull
?
[
null
]
:
[])
;
}
/**
...
...
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