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
fca04ae1
Unverified
Commit
fca04ae1
authored
Nov 11, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-494: Test against null for options with default values
parent
98fcbeab
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
37 deletions
+56
-37
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.
tests/ClientTest.php
View file @
fca04ae1
...
@@ -33,7 +33,7 @@ class ClientTest extends TestCase
...
@@ -33,7 +33,7 @@ class ClientTest extends TestCase
{
{
$options
=
[];
$options
=
[];
foreach
(
$this
->
getInvalidArrayValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidArrayValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'typeMap'
=>
$value
];
$options
[][]
=
[
'typeMap'
=>
$value
];
}
}
...
...
tests/GridFS/BucketFunctionalTest.php
View file @
fca04ae1
...
@@ -62,15 +62,15 @@ class BucketFunctionalTest extends FunctionalTestCase
...
@@ -62,15 +62,15 @@ class BucketFunctionalTest extends FunctionalTestCase
{
{
$options
=
[];
$options
=
[];
foreach
(
$this
->
getInvalidStringValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidStringValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'bucketName'
=>
$value
];
$options
[][]
=
[
'bucketName'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'disableMD5'
=>
$value
];
$options
[][]
=
[
'disableMD5'
=>
$value
];
}
}
...
...
tests/GridFS/WritableStreamFunctionalTest.php
View file @
fca04ae1
...
@@ -50,11 +50,11 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
...
@@ -50,11 +50,11 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
{
{
$options
=
[];
$options
=
[];
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
$options
[][]
=
[
'chunkSizeBytes'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'disableMD5'
=>
$value
];
$options
[][]
=
[
'disableMD5'
=>
$value
];
}
}
...
...
tests/Operation/AggregateTest.php
View file @
fca04ae1
...
@@ -27,7 +27,7 @@ class AggregateTest extends TestCase
...
@@ -27,7 +27,7 @@ class AggregateTest extends TestCase
{
{
$options
=
[];
$options
=
[];
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'allowDiskUse'
=>
$value
];
$options
[][]
=
[
'allowDiskUse'
=>
$value
];
}
}
...
@@ -79,7 +79,7 @@ class AggregateTest extends TestCase
...
@@ -79,7 +79,7 @@ class AggregateTest extends TestCase
$options
[][]
=
[
'typeMap'
=>
$value
];
$options
[][]
=
[
'typeMap'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'useCursor'
=>
$value
];
$options
[][]
=
[
'useCursor'
=>
$value
];
}
}
...
...
tests/Operation/BulkWriteTest.php
View file @
fca04ae1
...
@@ -412,7 +412,7 @@ class BulkWriteTest extends TestCase
...
@@ -412,7 +412,7 @@ class BulkWriteTest extends TestCase
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'ordered'
=>
$value
];
$options
[][]
=
[
'ordered'
=>
$value
];
}
}
...
...
tests/Operation/FindAndModifyTest.php
View file @
fca04ae1
...
@@ -40,7 +40,7 @@ class FindAndModifyTest extends TestCase
...
@@ -40,7 +40,7 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'new'
=>
$value
];
$options
[][]
=
[
'new'
=>
$value
];
}
}
...
@@ -48,7 +48,7 @@ class FindAndModifyTest extends TestCase
...
@@ -48,7 +48,7 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'query'
=>
$value
];
$options
[][]
=
[
'query'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'remove'
=>
$value
];
$options
[][]
=
[
'remove'
=>
$value
];
}
}
...
@@ -68,7 +68,7 @@ class FindAndModifyTest extends TestCase
...
@@ -68,7 +68,7 @@ class FindAndModifyTest extends TestCase
$options
[][]
=
[
'update'
=>
$value
];
$options
[][]
=
[
'update'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'upsert'
=>
$value
];
$options
[][]
=
[
'upsert'
=>
$value
];
}
}
...
...
tests/Operation/FindOneAndReplaceTest.php
View file @
fca04ae1
...
@@ -49,7 +49,7 @@ class FindOneAndReplaceTest extends TestCase
...
@@ -49,7 +49,7 @@ class FindOneAndReplaceTest extends TestCase
$options
[][]
=
[
'projection'
=>
$value
];
$options
[][]
=
[
'projection'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'returnDocument'
=>
$value
];
$options
[][]
=
[
'returnDocument'
=>
$value
];
}
}
...
...
tests/Operation/FindOneAndUpdateTest.php
View file @
fca04ae1
...
@@ -49,7 +49,7 @@ class FindOneAndUpdateTest extends TestCase
...
@@ -49,7 +49,7 @@ class FindOneAndUpdateTest extends TestCase
$options
[][]
=
[
'projection'
=>
$value
];
$options
[][]
=
[
'projection'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'returnDocument'
=>
$value
];
$options
[][]
=
[
'returnDocument'
=>
$value
];
}
}
...
...
tests/Operation/InsertManyTest.php
View file @
fca04ae1
...
@@ -48,7 +48,7 @@ class InsertManyTest extends TestCase
...
@@ -48,7 +48,7 @@ class InsertManyTest extends TestCase
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
$options
[][]
=
[
'bypassDocumentValidation'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'ordered'
=>
$value
];
$options
[][]
=
[
'ordered'
=>
$value
];
}
}
...
...
tests/Operation/UpdateTest.php
View file @
fca04ae1
...
@@ -52,7 +52,7 @@ class UpdateTest extends TestCase
...
@@ -52,7 +52,7 @@ class UpdateTest extends TestCase
$options
[][]
=
[
'collation'
=>
$value
];
$options
[][]
=
[
'collation'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'multi'
=>
$value
];
$options
[][]
=
[
'multi'
=>
$value
];
}
}
...
@@ -60,7 +60,7 @@ class UpdateTest extends TestCase
...
@@ -60,7 +60,7 @@ class UpdateTest extends TestCase
$options
[][]
=
[
'session'
=>
$value
];
$options
[][]
=
[
'session'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'upsert'
=>
$value
];
$options
[][]
=
[
'upsert'
=>
$value
];
}
}
...
...
tests/Operation/WatchTest.php
View file @
fca04ae1
...
@@ -52,7 +52,7 @@ class WatchTest extends FunctionalTestCase
...
@@ -52,7 +52,7 @@ class WatchTest extends FunctionalTestCase
$options
[][]
=
[
'collation'
=>
$value
];
$options
[][]
=
[
'collation'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidStringValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidStringValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'fullDocument'
=>
$value
];
$options
[][]
=
[
'fullDocument'
=>
$value
];
}
}
...
@@ -64,7 +64,7 @@ class WatchTest extends FunctionalTestCase
...
@@ -64,7 +64,7 @@ class WatchTest extends FunctionalTestCase
$options
[][]
=
[
'readConcern'
=>
$value
];
$options
[][]
=
[
'readConcern'
=>
$value
];
}
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
(
true
)
as
$value
)
{
$options
[][]
=
[
'readPreference'
=>
$value
];
$options
[][]
=
[
'readPreference'
=>
$value
];
}
}
...
...
tests/TestCase.php
View file @
fca04ae1
...
@@ -14,6 +14,7 @@ use ReflectionClass;
...
@@ -14,6 +14,7 @@ use ReflectionClass;
use
stdClass
;
use
stdClass
;
use
Traversable
;
use
Traversable
;
use
function
array_map
;
use
function
array_map
;
use
function
array_merge
;
use
function
array_values
;
use
function
array_values
;
use
function
call_user_func
;
use
function
call_user_func
;
use
function
getenv
;
use
function
getenv
;
...
@@ -165,91 +166,109 @@ abstract class TestCase extends BaseTestCase
...
@@ -165,91 +166,109 @@ abstract class TestCase extends BaseTestCase
/**
/**
* Return a list of invalid array values.
* Return a list of invalid array values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid boolean values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid document values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid integer values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid ReadPreference values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid ReadPreference values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid Session values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid string values.
*
*
* @param boolean $includeNull
*
* @return array
* @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.
* Return a list of invalid WriteConcern values.
*
*
* @param boolean $includeNull
*
* @return array
* @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