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
4043b265
Commit
4043b265
authored
Nov 01, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shorthand array syntax
parent
303de406
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
70 changed files
with
857 additions
and
874 deletions
+857
-874
Client.php
src/Client.php
+2
-2
Collection.php
src/Collection.php
+19
-19
Database.php
src/Database.php
+2
-2
CollectionInfo.php
src/Model/CollectionInfo.php
+1
-1
Aggregate.php
src/Operation/Aggregate.php
+6
-6
BulkWrite.php
src/Operation/BulkWrite.php
+8
-10
Count.php
src/Operation/Count.php
+3
-5
CreateCollection.php
src/Operation/CreateCollection.php
+4
-4
CreateIndexes.php
src/Operation/CreateIndexes.php
+3
-3
Delete.php
src/Operation/Delete.php
+2
-2
DeleteMany.php
src/Operation/DeleteMany.php
+1
-1
DeleteOne.php
src/Operation/DeleteOne.php
+1
-1
Distinct.php
src/Operation/Distinct.php
+3
-3
DropCollection.php
src/Operation/DropCollection.php
+1
-1
DropDatabase.php
src/Operation/DropDatabase.php
+1
-1
DropIndexes.php
src/Operation/DropIndexes.php
+2
-2
Find.php
src/Operation/Find.php
+4
-4
FindAndModify.php
src/Operation/FindAndModify.php
+4
-6
FindOne.php
src/Operation/FindOne.php
+2
-2
FindOneAndDelete.php
src/Operation/FindOneAndDelete.php
+2
-5
FindOneAndReplace.php
src/Operation/FindOneAndReplace.php
+4
-7
FindOneAndUpdate.php
src/Operation/FindOneAndUpdate.php
+4
-7
InsertMany.php
src/Operation/InsertMany.php
+3
-5
InsertOne.php
src/Operation/InsertOne.php
+1
-1
ListCollections.php
src/Operation/ListCollections.php
+7
-7
ListDatabases.php
src/Operation/ListDatabases.php
+3
-3
ListIndexes.php
src/Operation/ListIndexes.php
+7
-7
ReplaceOne.php
src/Operation/ReplaceOne.php
+2
-2
Update.php
src/Operation/Update.php
+5
-5
UpdateMany.php
src/Operation/UpdateMany.php
+2
-2
UpdateOne.php
src/Operation/UpdateOne.php
+2
-2
BulkWriteFunctionalTest.php
tests/Collection/BulkWriteFunctionalTest.php
+69
-69
CollectionFunctionalTest.php
tests/Collection/CollectionFunctionalTest.php
+15
-15
AggregateFunctionalTest.php
tests/Collection/CrudSpec/AggregateFunctionalTest.php
+18
-18
CountFunctionalTest.php
tests/Collection/CrudSpec/CountFunctionalTest.php
+3
-3
DeleteManyFunctionalTest.php
tests/Collection/CrudSpec/DeleteManyFunctionalTest.php
+10
-10
DeleteOneFunctionalTest.php
tests/Collection/CrudSpec/DeleteOneFunctionalTest.php
+16
-16
DistinctFunctionalTest.php
tests/Collection/CrudSpec/DistinctFunctionalTest.php
+3
-3
FindFunctionalTest.php
tests/Collection/CrudSpec/FindFunctionalTest.php
+21
-21
FindOneAndDeleteFunctionalTest.php
tests/Collection/CrudSpec/FindOneAndDeleteFunctionalTest.php
+30
-30
FindOneAndReplaceFunctionalTest.php
...s/Collection/CrudSpec/FindOneAndReplaceFunctionalTest.php
+96
-96
FindOneAndUpdateFunctionalTest.php
tests/Collection/CrudSpec/FindOneAndUpdateFunctionalTest.php
+96
-96
FunctionalTestCase.php
tests/Collection/CrudSpec/FunctionalTestCase.php
+2
-2
InsertManyFunctionalTest.php
tests/Collection/CrudSpec/InsertManyFunctionalTest.php
+10
-10
InsertOneFunctionalTest.php
tests/Collection/CrudSpec/InsertOneFunctionalTest.php
+5
-5
ReplaceOneFunctionalTest.php
tests/Collection/CrudSpec/ReplaceOneFunctionalTest.php
+39
-39
UpdateManyFunctionalTest.php
tests/Collection/CrudSpec/UpdateManyFunctionalTest.php
+30
-30
UpdateOneFunctionalTest.php
tests/Collection/CrudSpec/UpdateOneFunctionalTest.php
+30
-30
IndexManagementFunctionalTest.php
tests/Collection/IndexManagementFunctionalTest.php
+18
-18
CollectionManagementFunctionalTest.php
tests/Database/CollectionManagementFunctionalTest.php
+3
-3
DatabaseFunctionalTest.php
tests/Database/DatabaseFunctionalTest.php
+4
-4
FunctionalTestCase.php
tests/FunctionalTestCase.php
+4
-4
CollectionInfoTest.php
tests/Model/CollectionInfoTest.php
+11
-11
DatabaseInfoTest.php
tests/Model/DatabaseInfoTest.php
+6
-6
IndexInfoTest.php
tests/Model/IndexInfoTest.php
+19
-19
IndexInputTest.php
tests/Model/IndexInputTest.php
+20
-20
AggregateTest.php
tests/Operation/AggregateTest.php
+11
-11
BulkWriteTest.php
tests/Operation/BulkWriteTest.php
+89
-89
CountTest.php
tests/Operation/CountTest.php
+8
-8
DeleteTest.php
tests/Operation/DeleteTest.php
+5
-5
DistinctTest.php
tests/Operation/DistinctTest.php
+4
-4
FindTest.php
tests/Operation/FindTest.php
+16
-16
InsertManyTest.php
tests/Operation/InsertManyTest.php
+7
-7
InsertOneTest.php
tests/Operation/InsertOneTest.php
+3
-3
ReplaceOneTest.php
tests/Operation/ReplaceOneTest.php
+3
-3
TestCase.php
tests/Operation/TestCase.php
+8
-8
UpdateManyTest.php
tests/Operation/UpdateManyTest.php
+3
-3
UpdateOneTest.php
tests/Operation/UpdateOneTest.php
+3
-3
UpdateTest.php
tests/Operation/UpdateTest.php
+7
-7
PedantryTest.php
tests/PedantryTest.php
+1
-1
No files found.
src/Client.php
View file @
4043b265
...
@@ -27,7 +27,7 @@ class Client
...
@@ -27,7 +27,7 @@ class Client
* @param array $options Additional connection string options
* @param array $options Additional connection string options
* @param array $driverOptions Driver-specific options
* @param array $driverOptions Driver-specific options
*/
*/
public
function
__construct
(
$uri
,
array
$options
=
array
(),
array
$driverOptions
=
array
()
)
public
function
__construct
(
$uri
,
array
$options
=
[],
array
$driverOptions
=
[]
)
{
{
$this
->
manager
=
new
Manager
(
$uri
,
$options
,
$driverOptions
);
$this
->
manager
=
new
Manager
(
$uri
,
$options
,
$driverOptions
);
}
}
...
@@ -52,7 +52,7 @@ class Client
...
@@ -52,7 +52,7 @@ class Client
* @see ListDatabases::__construct() for supported options
* @see ListDatabases::__construct() for supported options
* @return DatabaseInfoIterator
* @return DatabaseInfoIterator
*/
*/
public
function
listDatabases
(
array
$options
=
array
()
)
public
function
listDatabases
(
array
$options
=
[]
)
{
{
$operation
=
new
ListDatabases
(
$options
);
$operation
=
new
ListDatabases
(
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
...
src/Collection.php
View file @
4043b265
...
@@ -93,7 +93,7 @@ class Collection
...
@@ -93,7 +93,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return Traversable
* @return Traversable
*/
*/
public
function
aggregate
(
array
$pipeline
,
array
$options
=
array
()
)
public
function
aggregate
(
array
$pipeline
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
readPreference
;
$options
[
'readPreference'
]
=
$this
->
readPreference
;
...
@@ -117,7 +117,7 @@ class Collection
...
@@ -117,7 +117,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return BulkWriteResult
* @return BulkWriteResult
*/
*/
public
function
bulkWrite
(
array
$operations
,
array
$options
=
array
()
)
public
function
bulkWrite
(
array
$operations
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -137,7 +137,7 @@ class Collection
...
@@ -137,7 +137,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return integer
* @return integer
*/
*/
public
function
count
(
$filter
=
array
(),
array
$options
=
array
()
)
public
function
count
(
$filter
=
[],
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
readPreference
;
$options
[
'readPreference'
]
=
$this
->
readPreference
;
...
@@ -158,9 +158,9 @@ class Collection
...
@@ -158,9 +158,9 @@ class Collection
* @param array $options Index options
* @param array $options Index options
* @return string The name of the created index
* @return string The name of the created index
*/
*/
public
function
createIndex
(
$key
,
array
$options
=
array
()
)
public
function
createIndex
(
$key
,
array
$options
=
[]
)
{
{
return
current
(
$this
->
createIndexes
(
array
(
array
(
'key'
=>
$key
)
+
$options
)
));
return
current
(
$this
->
createIndexes
(
[[
'key'
=>
$key
]
+
$options
]
));
}
}
/**
/**
...
@@ -203,7 +203,7 @@ class Collection
...
@@ -203,7 +203,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return DeleteResult
* @return DeleteResult
*/
*/
public
function
deleteMany
(
$filter
,
array
$options
=
array
()
)
public
function
deleteMany
(
$filter
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -224,7 +224,7 @@ class Collection
...
@@ -224,7 +224,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return DeleteResult
* @return DeleteResult
*/
*/
public
function
deleteOne
(
$filter
,
array
$options
=
array
()
)
public
function
deleteOne
(
$filter
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -245,7 +245,7 @@ class Collection
...
@@ -245,7 +245,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return mixed[]
* @return mixed[]
*/
*/
public
function
distinct
(
$fieldName
,
$filter
=
array
(),
array
$options
=
array
()
)
public
function
distinct
(
$fieldName
,
$filter
=
[],
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
readPreference
;
$options
[
'readPreference'
]
=
$this
->
readPreference
;
...
@@ -313,7 +313,7 @@ class Collection
...
@@ -313,7 +313,7 @@ class Collection
* @param array $options Additional options
* @param array $options Additional options
* @return Cursor
* @return Cursor
*/
*/
public
function
find
(
$filter
=
array
(),
array
$options
=
array
()
)
public
function
find
(
$filter
=
[],
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
readPreference
;
$options
[
'readPreference'
]
=
$this
->
readPreference
;
...
@@ -334,7 +334,7 @@ class Collection
...
@@ -334,7 +334,7 @@ class Collection
* @param array $options Additional options
* @param array $options Additional options
* @return object|null
* @return object|null
*/
*/
public
function
findOne
(
$filter
=
array
(),
array
$options
=
array
()
)
public
function
findOne
(
$filter
=
[],
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
if
(
!
isset
(
$options
[
'readPreference'
]))
{
$options
[
'readPreference'
]
=
$this
->
readPreference
;
$options
[
'readPreference'
]
=
$this
->
readPreference
;
...
@@ -357,7 +357,7 @@ class Collection
...
@@ -357,7 +357,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return object|null
* @return object|null
*/
*/
public
function
findOneAndDelete
(
$filter
,
array
$options
=
array
()
)
public
function
findOneAndDelete
(
$filter
,
array
$options
=
[]
)
{
{
$operation
=
new
FindOneAndDelete
(
$this
->
databaseName
,
$this
->
collectionName
,
$filter
,
$options
);
$operation
=
new
FindOneAndDelete
(
$this
->
databaseName
,
$this
->
collectionName
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
@@ -380,7 +380,7 @@ class Collection
...
@@ -380,7 +380,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return object|null
* @return object|null
*/
*/
public
function
findOneAndReplace
(
$filter
,
$replacement
,
array
$options
=
array
()
)
public
function
findOneAndReplace
(
$filter
,
$replacement
,
array
$options
=
[]
)
{
{
$operation
=
new
FindOneAndReplace
(
$this
->
databaseName
,
$this
->
collectionName
,
$filter
,
$replacement
,
$options
);
$operation
=
new
FindOneAndReplace
(
$this
->
databaseName
,
$this
->
collectionName
,
$filter
,
$replacement
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
@@ -403,7 +403,7 @@ class Collection
...
@@ -403,7 +403,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return object|null
* @return object|null
*/
*/
public
function
findOneAndUpdate
(
$filter
,
$update
,
array
$options
=
array
()
)
public
function
findOneAndUpdate
(
$filter
,
$update
,
array
$options
=
[]
)
{
{
$operation
=
new
FindOneAndUpdate
(
$this
->
databaseName
,
$this
->
collectionName
,
$filter
,
$update
,
$options
);
$operation
=
new
FindOneAndUpdate
(
$this
->
databaseName
,
$this
->
collectionName
,
$filter
,
$update
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
@@ -451,7 +451,7 @@ class Collection
...
@@ -451,7 +451,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return InsertManyResult
* @return InsertManyResult
*/
*/
public
function
insertMany
(
array
$documents
,
array
$options
=
array
()
)
public
function
insertMany
(
array
$documents
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -472,7 +472,7 @@ class Collection
...
@@ -472,7 +472,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return InsertOneResult
* @return InsertOneResult
*/
*/
public
function
insertOne
(
$document
,
array
$options
=
array
()
)
public
function
insertOne
(
$document
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -490,7 +490,7 @@ class Collection
...
@@ -490,7 +490,7 @@ class Collection
* @see ListIndexes::__construct() for supported options
* @see ListIndexes::__construct() for supported options
* @return IndexInfoIterator
* @return IndexInfoIterator
*/
*/
public
function
listIndexes
(
array
$options
=
array
()
)
public
function
listIndexes
(
array
$options
=
[]
)
{
{
$operation
=
new
ListIndexes
(
$this
->
databaseName
,
$this
->
collectionName
,
$options
);
$operation
=
new
ListIndexes
(
$this
->
databaseName
,
$this
->
collectionName
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
@@ -508,7 +508,7 @@ class Collection
...
@@ -508,7 +508,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return UpdateResult
* @return UpdateResult
*/
*/
public
function
replaceOne
(
$filter
,
$replacement
,
array
$options
=
array
()
)
public
function
replaceOne
(
$filter
,
$replacement
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -530,7 +530,7 @@ class Collection
...
@@ -530,7 +530,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return UpdateResult
* @return UpdateResult
*/
*/
public
function
updateMany
(
$filter
,
$update
,
array
$options
=
array
()
)
public
function
updateMany
(
$filter
,
$update
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
@@ -552,7 +552,7 @@ class Collection
...
@@ -552,7 +552,7 @@ class Collection
* @param array $options Command options
* @param array $options Command options
* @return UpdateResult
* @return UpdateResult
*/
*/
public
function
updateOne
(
$filter
,
$update
,
array
$options
=
array
()
)
public
function
updateOne
(
$filter
,
$update
,
array
$options
=
[]
)
{
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
if
(
!
isset
(
$options
[
'writeConcern'
]))
{
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
$options
[
'writeConcern'
]
=
$this
->
writeConcern
;
...
...
src/Database.php
View file @
4043b265
...
@@ -66,7 +66,7 @@ class Database
...
@@ -66,7 +66,7 @@ class Database
* @param array $options
* @param array $options
* @return object Command result document
* @return object Command result document
*/
*/
public
function
createCollection
(
$collectionName
,
array
$options
=
array
()
)
public
function
createCollection
(
$collectionName
,
array
$options
=
[]
)
{
{
$operation
=
new
CreateCollection
(
$this
->
databaseName
,
$collectionName
,
$options
);
$operation
=
new
CreateCollection
(
$this
->
databaseName
,
$collectionName
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
@@ -118,7 +118,7 @@ class Database
...
@@ -118,7 +118,7 @@ class Database
* @param array $options
* @param array $options
* @return CollectionInfoIterator
* @return CollectionInfoIterator
*/
*/
public
function
listCollections
(
array
$options
=
array
()
)
public
function
listCollections
(
array
$options
=
[]
)
{
{
$operation
=
new
ListCollections
(
$this
->
databaseName
,
$options
);
$operation
=
new
ListCollections
(
$this
->
databaseName
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
...
...
src/Model/CollectionInfo.php
View file @
4043b265
...
@@ -75,7 +75,7 @@ class CollectionInfo
...
@@ -75,7 +75,7 @@ class CollectionInfo
*/
*/
public
function
getOptions
()
public
function
getOptions
()
{
{
return
isset
(
$this
->
info
[
'options'
])
?
(
array
)
$this
->
info
[
'options'
]
:
array
()
;
return
isset
(
$this
->
info
[
'options'
])
?
(
array
)
$this
->
info
[
'options'
]
:
[]
;
}
}
/**
/**
...
...
src/Operation/Aggregate.php
View file @
4043b265
...
@@ -60,7 +60,7 @@ class Aggregate implements Executable
...
@@ -60,7 +60,7 @@ class Aggregate implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$pipeline
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$pipeline
,
array
$options
=
[]
)
{
{
if
(
empty
(
$pipeline
))
{
if
(
empty
(
$pipeline
))
{
throw
new
InvalidArgumentException
(
'$pipeline is empty'
);
throw
new
InvalidArgumentException
(
'$pipeline is empty'
);
...
@@ -80,10 +80,10 @@ class Aggregate implements Executable
...
@@ -80,10 +80,10 @@ class Aggregate implements Executable
$expectedIndex
+=
1
;
$expectedIndex
+=
1
;
}
}
$options
+=
array
(
$options
+=
[
'allowDiskUse'
=>
false
,
'allowDiskUse'
=>
false
,
'useCursor'
=>
true
,
'useCursor'
=>
true
,
)
;
]
;
if
(
!
is_bool
(
$options
[
'allowDiskUse'
]))
{
if
(
!
is_bool
(
$options
[
'allowDiskUse'
]))
{
throw
new
InvalidArgumentTypeException
(
'"allowDiskUse" option'
,
$options
[
'allowDiskUse'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
'"allowDiskUse" option'
,
$options
[
'allowDiskUse'
],
'boolean'
);
...
@@ -156,10 +156,10 @@ class Aggregate implements Executable
...
@@ -156,10 +156,10 @@ class Aggregate implements Executable
*/
*/
private
function
createCommand
(
Server
$server
,
$isCursorSupported
)
private
function
createCommand
(
Server
$server
,
$isCursorSupported
)
{
{
$cmd
=
array
(
$cmd
=
[
'aggregate'
=>
$this
->
collectionName
,
'aggregate'
=>
$this
->
collectionName
,
'pipeline'
=>
$this
->
pipeline
,
'pipeline'
=>
$this
->
pipeline
,
)
;
]
;
// Servers < 2.6 do not support any command options
// Servers < 2.6 do not support any command options
if
(
!
$isCursorSupported
)
{
if
(
!
$isCursorSupported
)
{
...
@@ -174,7 +174,7 @@ class Aggregate implements Executable
...
@@ -174,7 +174,7 @@ class Aggregate implements Executable
if
(
$this
->
options
[
'useCursor'
])
{
if
(
$this
->
options
[
'useCursor'
])
{
$cmd
[
'cursor'
]
=
isset
(
$this
->
options
[
"batchSize"
])
$cmd
[
'cursor'
]
=
isset
(
$this
->
options
[
"batchSize"
])
?
array
(
'batchSize'
=>
$this
->
options
[
"batchSize"
])
?
[
'batchSize'
=>
$this
->
options
[
"batchSize"
]]
:
new
stdClass
;
:
new
stdClass
;
}
}
...
...
src/Operation/BulkWrite.php
View file @
4043b265
...
@@ -66,7 +66,7 @@ class BulkWrite implements Executable
...
@@ -66,7 +66,7 @@ class BulkWrite implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$operations
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$operations
,
array
$options
=
[]
)
{
{
if
(
empty
(
$operations
))
{
if
(
empty
(
$operations
))
{
throw
new
InvalidArgumentException
(
'$operations is empty'
);
throw
new
InvalidArgumentException
(
'$operations is empty'
);
...
@@ -104,7 +104,7 @@ class BulkWrite implements Executable
...
@@ -104,7 +104,7 @@ class BulkWrite implements Executable
case
self
::
DELETE_MANY
:
case
self
::
DELETE_MANY
:
case
self
::
DELETE_ONE
:
case
self
::
DELETE_ONE
:
$operations
[
$i
][
$type
][
1
]
=
array
(
'limit'
=>
(
$type
===
self
::
DELETE_ONE
?
1
:
0
))
;
$operations
[
$i
][
$type
][
1
]
=
[
'limit'
=>
(
$type
===
self
::
DELETE_ONE
?
1
:
0
)]
;
break
;
break
;
...
@@ -122,7 +122,7 @@ class BulkWrite implements Executable
...
@@ -122,7 +122,7 @@ class BulkWrite implements Executable
}
}
if
(
!
isset
(
$args
[
2
]))
{
if
(
!
isset
(
$args
[
2
]))
{
$args
[
2
]
=
array
()
;
$args
[
2
]
=
[]
;
}
}
if
(
!
is_array
(
$args
[
2
]))
{
if
(
!
is_array
(
$args
[
2
]))
{
...
@@ -130,7 +130,7 @@ class BulkWrite implements Executable
...
@@ -130,7 +130,7 @@ class BulkWrite implements Executable
}
}
$args
[
2
][
'multi'
]
=
false
;
$args
[
2
][
'multi'
]
=
false
;
$args
[
2
]
+=
array
(
'upsert'
=>
false
)
;
$args
[
2
]
+=
[
'upsert'
=>
false
]
;
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
...
@@ -155,7 +155,7 @@ class BulkWrite implements Executable
...
@@ -155,7 +155,7 @@ class BulkWrite implements Executable
}
}
if
(
!
isset
(
$args
[
2
]))
{
if
(
!
isset
(
$args
[
2
]))
{
$args
[
2
]
=
array
()
;
$args
[
2
]
=
[]
;
}
}
if
(
!
is_array
(
$args
[
2
]))
{
if
(
!
is_array
(
$args
[
2
]))
{
...
@@ -163,7 +163,7 @@ class BulkWrite implements Executable
...
@@ -163,7 +163,7 @@ class BulkWrite implements Executable
}
}
$args
[
2
][
'multi'
]
=
(
$type
===
self
::
UPDATE_MANY
);
$args
[
2
][
'multi'
]
=
(
$type
===
self
::
UPDATE_MANY
);
$args
[
2
]
+=
array
(
'upsert'
=>
false
)
;
$args
[
2
]
+=
[
'upsert'
=>
false
]
;
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
if
(
!
is_bool
(
$args
[
2
][
'upsert'
]))
{
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
sprintf
(
'$operations[%d]["%s"][2]["upsert"]'
,
$i
,
$type
),
$args
[
2
][
'upsert'
],
'boolean'
);
...
@@ -180,9 +180,7 @@ class BulkWrite implements Executable
...
@@ -180,9 +180,7 @@ class BulkWrite implements Executable
$expectedIndex
+=
1
;
$expectedIndex
+=
1
;
}
}
$options
+=
array
(
$options
+=
[
'ordered'
=>
true
];
'ordered'
=>
true
,
);
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
throw
new
InvalidArgumentTypeException
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
...
@@ -208,7 +206,7 @@ class BulkWrite implements Executable
...
@@ -208,7 +206,7 @@ class BulkWrite implements Executable
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$bulk
=
new
Bulk
([
'ordered'
=>
$this
->
options
[
'ordered'
]]);
$bulk
=
new
Bulk
([
'ordered'
=>
$this
->
options
[
'ordered'
]]);
$insertedIds
=
array
()
;
$insertedIds
=
[]
;
foreach
(
$this
->
operations
as
$i
=>
$operation
)
{
foreach
(
$this
->
operations
as
$i
=>
$operation
)
{
$type
=
key
(
$operation
);
$type
=
key
(
$operation
);
...
...
src/Operation/Count.php
View file @
4043b265
...
@@ -48,7 +48,7 @@ class Count implements Executable
...
@@ -48,7 +48,7 @@ class Count implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
=
array
(),
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
=
[],
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -119,15 +119,13 @@ class Count implements Executable
...
@@ -119,15 +119,13 @@ class Count implements Executable
*/
*/
private
function
createCommand
()
private
function
createCommand
()
{
{
$cmd
=
array
(
$cmd
=
[
'count'
=>
$this
->
collectionName
];
'count'
=>
$this
->
collectionName
,
);
if
(
!
empty
(
$this
->
filter
))
{
if
(
!
empty
(
$this
->
filter
))
{
$cmd
[
'query'
]
=
(
object
)
$this
->
filter
;
$cmd
[
'query'
]
=
(
object
)
$this
->
filter
;
}
}
foreach
(
array
(
'hint'
,
'limit'
,
'maxTimeMS'
,
'skip'
)
as
$option
)
{
foreach
(
[
'hint'
,
'limit'
,
'maxTimeMS'
,
'skip'
]
as
$option
)
{
if
(
isset
(
$this
->
options
[
$option
]))
{
if
(
isset
(
$this
->
options
[
$option
]))
{
$cmd
[
$option
]
=
$this
->
options
[
$option
];
$cmd
[
$option
]
=
$this
->
options
[
$option
];
}
}
...
...
src/Operation/CreateCollection.php
View file @
4043b265
...
@@ -23,7 +23,7 @@ class CreateCollection implements Executable
...
@@ -23,7 +23,7 @@ class CreateCollection implements Executable
private
$databaseName
;
private
$databaseName
;
private
$collectionName
;
private
$collectionName
;
private
$options
=
array
()
;
private
$options
=
[]
;
/**
/**
* Constructs a create command.
* Constructs a create command.
...
@@ -57,7 +57,7 @@ class CreateCollection implements Executable
...
@@ -57,7 +57,7 @@ class CreateCollection implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[]
)
{
{
if
(
isset
(
$options
[
'autoIndexId'
])
&&
!
is_bool
(
$options
[
'autoIndexId'
]))
{
if
(
isset
(
$options
[
'autoIndexId'
])
&&
!
is_bool
(
$options
[
'autoIndexId'
]))
{
throw
new
InvalidArgumentTypeException
(
'"autoIndexId" option'
,
$options
[
'autoIndexId'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
'"autoIndexId" option'
,
$options
[
'autoIndexId'
],
'boolean'
);
...
@@ -118,9 +118,9 @@ class CreateCollection implements Executable
...
@@ -118,9 +118,9 @@ class CreateCollection implements Executable
*/
*/
private
function
createCommand
()
private
function
createCommand
()
{
{
$cmd
=
array
(
'create'
=>
$this
->
collectionName
)
;
$cmd
=
[
'create'
=>
$this
->
collectionName
]
;
foreach
(
array
(
'autoIndexId'
,
'capped'
,
'flags'
,
'max'
,
'maxTimeMS'
,
'size'
)
as
$option
)
{
foreach
(
[
'autoIndexId'
,
'capped'
,
'flags'
,
'max'
,
'maxTimeMS'
,
'size'
]
as
$option
)
{
if
(
isset
(
$this
->
options
[
$option
]))
{
if
(
isset
(
$this
->
options
[
$option
]))
{
$cmd
[
$option
]
=
$this
->
options
[
$option
];
$cmd
[
$option
]
=
$this
->
options
[
$option
];
}
}
...
...
src/Operation/CreateIndexes.php
View file @
4043b265
...
@@ -24,7 +24,7 @@ class CreateIndexes implements Executable
...
@@ -24,7 +24,7 @@ class CreateIndexes implements Executable
private
$databaseName
;
private
$databaseName
;
private
$collectionName
;
private
$collectionName
;
private
$indexes
=
array
()
;
private
$indexes
=
[]
;
/**
/**
* Constructs a createIndexes command.
* Constructs a createIndexes command.
...
@@ -85,10 +85,10 @@ class CreateIndexes implements Executable
...
@@ -85,10 +85,10 @@ class CreateIndexes implements Executable
*/
*/
private
function
executeCommand
(
Server
$server
)
private
function
executeCommand
(
Server
$server
)
{
{
$command
=
new
Command
(
array
(
$command
=
new
Command
(
[
'createIndexes'
=>
$this
->
collectionName
,
'createIndexes'
=>
$this
->
collectionName
,
'indexes'
=>
$this
->
indexes
,
'indexes'
=>
$this
->
indexes
,
)
);
]
);
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$command
);
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$command
);
$result
=
current
(
$cursor
->
toArray
());
$result
=
current
(
$cursor
->
toArray
());
...
...
src/Operation/Delete.php
View file @
4043b265
...
@@ -42,7 +42,7 @@ class Delete implements Executable
...
@@ -42,7 +42,7 @@ class Delete implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$limit
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$limit
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -73,7 +73,7 @@ class Delete implements Executable
...
@@ -73,7 +73,7 @@ class Delete implements Executable
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$bulk
=
new
Bulk
();
$bulk
=
new
Bulk
();
$bulk
->
delete
(
$this
->
filter
,
array
(
'limit'
=>
$this
->
limit
)
);
$bulk
->
delete
(
$this
->
filter
,
[
'limit'
=>
$this
->
limit
]
);
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeConcern
=
isset
(
$this
->
options
[
'writeConcern'
])
?
$this
->
options
[
'writeConcern'
]
:
null
;
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
$writeResult
=
$server
->
executeBulkWrite
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$bulk
,
$writeConcern
);
...
...
src/Operation/DeleteMany.php
View file @
4043b265
...
@@ -30,7 +30,7 @@ class DeleteMany implements Executable
...
@@ -30,7 +30,7 @@ class DeleteMany implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[]
)
{
{
$this
->
delete
=
new
Delete
(
$databaseName
,
$collectionName
,
$filter
,
0
,
$options
);
$this
->
delete
=
new
Delete
(
$databaseName
,
$collectionName
,
$filter
,
0
,
$options
);
}
}
...
...
src/Operation/DeleteOne.php
View file @
4043b265
...
@@ -30,7 +30,7 @@ class DeleteOne implements Executable
...
@@ -30,7 +30,7 @@ class DeleteOne implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[]
)
{
{
$this
->
delete
=
new
Delete
(
$databaseName
,
$collectionName
,
$filter
,
1
,
$options
);
$this
->
delete
=
new
Delete
(
$databaseName
,
$collectionName
,
$filter
,
1
,
$options
);
}
}
...
...
src/Operation/Distinct.php
View file @
4043b265
...
@@ -42,7 +42,7 @@ class Distinct implements Executable
...
@@ -42,7 +42,7 @@ class Distinct implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$fieldName
,
$filter
=
array
(),
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$fieldName
,
$filter
=
[],
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -95,10 +95,10 @@ class Distinct implements Executable
...
@@ -95,10 +95,10 @@ class Distinct implements Executable
*/
*/
private
function
createCommand
()
private
function
createCommand
()
{
{
$cmd
=
array
(
$cmd
=
[
'distinct'
=>
$this
->
collectionName
,
'distinct'
=>
$this
->
collectionName
,
'key'
=>
$this
->
fieldName
,
'key'
=>
$this
->
fieldName
,
)
;
]
;
if
(
!
empty
(
$this
->
filter
))
{
if
(
!
empty
(
$this
->
filter
))
{
$cmd
[
'query'
]
=
(
object
)
$this
->
filter
;
$cmd
[
'query'
]
=
(
object
)
$this
->
filter
;
...
...
src/Operation/DropCollection.php
View file @
4043b265
...
@@ -43,7 +43,7 @@ class DropCollection implements Executable
...
@@ -43,7 +43,7 @@ class DropCollection implements Executable
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
try
{
try
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
array
(
'drop'
=>
$this
->
collectionName
)
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
[
'drop'
=>
$this
->
collectionName
]
));
}
catch
(
DriverRuntimeException
$e
)
{
}
catch
(
DriverRuntimeException
$e
)
{
/* The server may return an error if the collection does not exist.
/* The server may return an error if the collection does not exist.
* Check for an error message (unfortunately, there isn't a code)
* Check for an error message (unfortunately, there isn't a code)
...
...
src/Operation/DropDatabase.php
View file @
4043b265
...
@@ -38,7 +38,7 @@ class DropDatabase implements Executable
...
@@ -38,7 +38,7 @@ class DropDatabase implements Executable
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
array
(
'dropDatabase'
=>
1
)
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
[
'dropDatabase'
=>
1
]
));
$result
=
current
(
$cursor
->
toArray
());
$result
=
current
(
$cursor
->
toArray
());
if
(
empty
(
$result
->
ok
))
{
if
(
empty
(
$result
->
ok
))
{
...
...
src/Operation/DropIndexes.php
View file @
4043b265
...
@@ -50,10 +50,10 @@ class DropIndexes implements Executable
...
@@ -50,10 +50,10 @@ class DropIndexes implements Executable
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$cmd
=
array
(
$cmd
=
[
'dropIndexes'
=>
$this
->
collectionName
,
'dropIndexes'
=>
$this
->
collectionName
,
'index'
=>
$this
->
indexName
,
'index'
=>
$this
->
indexName
,
)
;
]
;
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$result
=
current
(
$cursor
->
toArray
());
$result
=
current
(
$cursor
->
toArray
());
...
...
src/Operation/Find.php
View file @
4043b265
...
@@ -79,7 +79,7 @@ class Find implements Executable
...
@@ -79,7 +79,7 @@ class Find implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -172,7 +172,7 @@ class Find implements Executable
...
@@ -172,7 +172,7 @@ class Find implements Executable
*/
*/
private
function
createQuery
()
private
function
createQuery
()
{
{
$options
=
array
()
;
$options
=
[]
;
if
(
!
empty
(
$this
->
options
[
'allowPartialResults'
]))
{
if
(
!
empty
(
$this
->
options
[
'allowPartialResults'
]))
{
$options
[
'partial'
]
=
true
;
$options
[
'partial'
]
=
true
;
...
@@ -188,13 +188,13 @@ class Find implements Executable
...
@@ -188,13 +188,13 @@ class Find implements Executable
}
}
}
}
foreach
(
array
(
'batchSize'
,
'limit'
,
'skip'
,
'sort'
,
'noCursorTimeout'
,
'oplogReplay'
,
'projection'
)
as
$option
)
{
foreach
(
[
'batchSize'
,
'limit'
,
'skip'
,
'sort'
,
'noCursorTimeout'
,
'oplogReplay'
,
'projection'
]
as
$option
)
{
if
(
isset
(
$this
->
options
[
$option
]))
{
if
(
isset
(
$this
->
options
[
$option
]))
{
$options
[
$option
]
=
$this
->
options
[
$option
];
$options
[
$option
]
=
$this
->
options
[
$option
];
}
}
}
}
$modifiers
=
empty
(
$this
->
options
[
'modifiers'
])
?
array
()
:
(
array
)
$this
->
options
[
'modifiers'
];
$modifiers
=
empty
(
$this
->
options
[
'modifiers'
])
?
[]
:
(
array
)
$this
->
options
[
'modifiers'
];
if
(
isset
(
$options
[
'comment'
]))
{
if
(
isset
(
$options
[
'comment'
]))
{
$modifiers
[
'$comment'
]
=
$options
[
'comment'
];
$modifiers
[
'$comment'
]
=
$options
[
'comment'
];
...
...
src/Operation/FindAndModify.php
View file @
4043b265
...
@@ -61,11 +61,11 @@ class FindAndModify implements Executable
...
@@ -61,11 +61,11 @@ class FindAndModify implements Executable
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
)
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
)
{
{
$options
+=
array
(
$options
+=
[
'new'
=>
false
,
'new'
=>
false
,
'remove'
=>
false
,
'remove'
=>
false
,
'upsert'
=>
false
,
'upsert'
=>
false
,
)
;
]
;
if
(
isset
(
$options
[
'fields'
])
&&
!
is_array
(
$options
[
'fields'
])
&&
!
is_object
(
$options
[
'fields'
]))
{
if
(
isset
(
$options
[
'fields'
])
&&
!
is_array
(
$options
[
'fields'
])
&&
!
is_object
(
$options
[
'fields'
]))
{
throw
new
InvalidArgumentTypeException
(
'"fields" option'
,
$options
[
'fields'
],
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'"fields" option'
,
$options
[
'fields'
],
'array or object'
);
...
@@ -153,9 +153,7 @@ class FindAndModify implements Executable
...
@@ -153,9 +153,7 @@ class FindAndModify implements Executable
*/
*/
private
function
createCommand
()
private
function
createCommand
()
{
{
$cmd
=
array
(
$cmd
=
[
'findAndModify'
=>
$this
->
collectionName
];
'findAndModify'
=>
$this
->
collectionName
,
);
if
(
$this
->
options
[
'remove'
])
{
if
(
$this
->
options
[
'remove'
])
{
$cmd
[
'remove'
]
=
true
;
$cmd
[
'remove'
]
=
true
;
...
@@ -164,7 +162,7 @@ class FindAndModify implements Executable
...
@@ -164,7 +162,7 @@ class FindAndModify implements Executable
$cmd
[
'upsert'
]
=
$this
->
options
[
'upsert'
];
$cmd
[
'upsert'
]
=
$this
->
options
[
'upsert'
];
}
}
foreach
(
array
(
'fields'
,
'query'
,
'sort'
,
'update'
)
as
$option
)
{
foreach
(
[
'fields'
,
'query'
,
'sort'
,
'update'
]
as
$option
)
{
if
(
isset
(
$this
->
options
[
$option
]))
{
if
(
isset
(
$this
->
options
[
$option
]))
{
$cmd
[
$option
]
=
(
object
)
$this
->
options
[
$option
];
$cmd
[
$option
]
=
(
object
)
$this
->
options
[
$option
];
}
}
...
...
src/Operation/FindOne.php
View file @
4043b265
...
@@ -52,7 +52,7 @@ class FindOne implements Executable
...
@@ -52,7 +52,7 @@ class FindOne implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[]
)
{
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
if
(
isset
(
$options
[
'typeMap'
])
&&
!
is_array
(
$options
[
'typeMap'
]))
{
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
throw
new
InvalidArgumentTypeException
(
'"typeMap" option'
,
$options
[
'typeMap'
],
'array'
);
...
@@ -62,7 +62,7 @@ class FindOne implements Executable
...
@@ -62,7 +62,7 @@ class FindOne implements Executable
$databaseName
,
$databaseName
,
$collectionName
,
$collectionName
,
$filter
,
$filter
,
array
(
'limit'
=>
-
1
)
+
$options
[
'limit'
=>
-
1
]
+
$options
);
);
$this
->
options
=
$options
;
$this
->
options
=
$options
;
...
...
src/Operation/FindOneAndDelete.php
View file @
4043b265
...
@@ -38,7 +38,7 @@ class FindOneAndDelete implements Executable
...
@@ -38,7 +38,7 @@ class FindOneAndDelete implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -57,10 +57,7 @@ class FindOneAndDelete implements Executable
...
@@ -57,10 +57,7 @@ class FindOneAndDelete implements Executable
$this
->
findAndModify
=
new
FindAndModify
(
$this
->
findAndModify
=
new
FindAndModify
(
$databaseName
,
$databaseName
,
$collectionName
,
$collectionName
,
array
(
[
'query'
=>
$filter
,
'remove'
=>
true
]
+
$options
'query'
=>
$filter
,
'remove'
=>
true
,
)
+
$options
);
);
}
}
...
...
src/Operation/FindOneAndReplace.php
View file @
4043b265
...
@@ -49,7 +49,7 @@ class FindOneAndReplace implements Executable
...
@@ -49,7 +49,7 @@ class FindOneAndReplace implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -63,10 +63,10 @@ class FindOneAndReplace implements Executable
...
@@ -63,10 +63,10 @@ class FindOneAndReplace implements Executable
throw
new
InvalidArgumentException
(
'First key in $replacement argument is an update operator'
);
throw
new
InvalidArgumentException
(
'First key in $replacement argument is an update operator'
);
}
}
$options
+=
array
(
$options
+=
[
'returnDocument'
=>
self
::
RETURN_DOCUMENT_BEFORE
,
'returnDocument'
=>
self
::
RETURN_DOCUMENT_BEFORE
,
'upsert'
=>
false
,
'upsert'
=>
false
,
)
;
]
;
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
...
@@ -92,10 +92,7 @@ class FindOneAndReplace implements Executable
...
@@ -92,10 +92,7 @@ class FindOneAndReplace implements Executable
$this
->
findAndModify
=
new
FindAndModify
(
$this
->
findAndModify
=
new
FindAndModify
(
$databaseName
,
$databaseName
,
$collectionName
,
$collectionName
,
array
(
[
'query'
=>
$filter
,
'update'
=>
$replacement
]
+
$options
'query'
=>
$filter
,
'update'
=>
$replacement
,
)
+
$options
);
);
}
}
...
...
src/Operation/FindOneAndUpdate.php
View file @
4043b265
...
@@ -49,7 +49,7 @@ class FindOneAndUpdate implements Executable
...
@@ -49,7 +49,7 @@ class FindOneAndUpdate implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -63,10 +63,10 @@ class FindOneAndUpdate implements Executable
...
@@ -63,10 +63,10 @@ class FindOneAndUpdate implements Executable
throw
new
InvalidArgumentException
(
'First key in $update argument is not an update operator'
);
throw
new
InvalidArgumentException
(
'First key in $update argument is not an update operator'
);
}
}
$options
+=
array
(
$options
+=
[
'returnDocument'
=>
self
::
RETURN_DOCUMENT_BEFORE
,
'returnDocument'
=>
self
::
RETURN_DOCUMENT_BEFORE
,
'upsert'
=>
false
,
'upsert'
=>
false
,
)
;
]
;
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
if
(
isset
(
$options
[
'projection'
])
&&
!
is_array
(
$options
[
'projection'
])
&&
!
is_object
(
$options
[
'projection'
]))
{
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'"projection" option'
,
$options
[
'projection'
],
'array or object'
);
...
@@ -92,10 +92,7 @@ class FindOneAndUpdate implements Executable
...
@@ -92,10 +92,7 @@ class FindOneAndUpdate implements Executable
$this
->
findAndModify
=
new
FindAndModify
(
$this
->
findAndModify
=
new
FindAndModify
(
$databaseName
,
$databaseName
,
$collectionName
,
$collectionName
,
array
(
[
'query'
=>
$filter
,
'update'
=>
$update
]
+
$options
'query'
=>
$filter
,
'update'
=>
$update
,
)
+
$options
);
);
}
}
...
...
src/Operation/InsertMany.php
View file @
4043b265
...
@@ -40,7 +40,7 @@ class InsertMany implements Executable
...
@@ -40,7 +40,7 @@ class InsertMany implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$documents
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$documents
,
array
$options
=
[]
)
{
{
if
(
empty
(
$documents
))
{
if
(
empty
(
$documents
))
{
throw
new
InvalidArgumentException
(
'$documents is empty'
);
throw
new
InvalidArgumentException
(
'$documents is empty'
);
...
@@ -60,9 +60,7 @@ class InsertMany implements Executable
...
@@ -60,9 +60,7 @@ class InsertMany implements Executable
$expectedIndex
+=
1
;
$expectedIndex
+=
1
;
}
}
$options
+=
array
(
$options
+=
[
'ordered'
=>
true
];
'ordered'
=>
true
,
);
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
if
(
!
is_bool
(
$options
[
'ordered'
]))
{
throw
new
InvalidArgumentTypeException
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
'"ordered" option'
,
$options
[
'ordered'
],
'boolean'
);
...
@@ -88,7 +86,7 @@ class InsertMany implements Executable
...
@@ -88,7 +86,7 @@ class InsertMany implements Executable
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$bulk
=
new
Bulk
([
'ordered'
=>
$this
->
options
[
'ordered'
]]);
$bulk
=
new
Bulk
([
'ordered'
=>
$this
->
options
[
'ordered'
]]);
$insertedIds
=
array
()
;
$insertedIds
=
[]
;
foreach
(
$this
->
documents
as
$i
=>
$document
)
{
foreach
(
$this
->
documents
as
$i
=>
$document
)
{
$insertedId
=
$bulk
->
insert
(
$document
);
$insertedId
=
$bulk
->
insert
(
$document
);
...
...
src/Operation/InsertOne.php
View file @
4043b265
...
@@ -35,7 +35,7 @@ class InsertOne implements Executable
...
@@ -35,7 +35,7 @@ class InsertOne implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$document
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$document
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$document
)
&&
!
is_object
(
$document
))
{
if
(
!
is_array
(
$document
)
&&
!
is_object
(
$document
))
{
throw
new
InvalidArgumentTypeException
(
'$document'
,
$document
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$document'
,
$document
,
'array or object'
);
...
...
src/Operation/ListCollections.php
View file @
4043b265
...
@@ -37,7 +37,7 @@ class ListCollections implements Executable
...
@@ -37,7 +37,7 @@ class ListCollections implements Executable
* @param string $databaseName Database name
* @param string $databaseName Database name
* @param array $options Command options
* @param array $options Command options
*/
*/
public
function
__construct
(
$databaseName
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
array
$options
=
[]
)
{
{
if
(
isset
(
$options
[
'filter'
])
&&
!
is_array
(
$options
[
'filter'
])
&&
!
is_object
(
$options
[
'filter'
]))
{
if
(
isset
(
$options
[
'filter'
])
&&
!
is_array
(
$options
[
'filter'
])
&&
!
is_object
(
$options
[
'filter'
]))
{
throw
new
InvalidArgumentTypeException
(
'"filter" option'
,
$options
[
'filter'
],
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'"filter" option'
,
$options
[
'filter'
],
'array or object'
);
...
@@ -74,7 +74,7 @@ class ListCollections implements Executable
...
@@ -74,7 +74,7 @@ class ListCollections implements Executable
*/
*/
private
function
executeCommand
(
Server
$server
)
private
function
executeCommand
(
Server
$server
)
{
{
$cmd
=
array
(
'listCollections'
=>
1
)
;
$cmd
=
[
'listCollections'
=>
1
]
;
if
(
!
empty
(
$this
->
options
[
'filter'
]))
{
if
(
!
empty
(
$this
->
options
[
'filter'
]))
{
$cmd
[
'filter'
]
=
(
object
)
$this
->
options
[
'filter'
];
$cmd
[
'filter'
]
=
(
object
)
$this
->
options
[
'filter'
];
...
@@ -85,7 +85,7 @@ class ListCollections implements Executable
...
@@ -85,7 +85,7 @@ class ListCollections implements Executable
}
}
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
return
new
CollectionInfoCommandIterator
(
$cursor
);
return
new
CollectionInfoCommandIterator
(
$cursor
);
}
}
...
@@ -100,7 +100,7 @@ class ListCollections implements Executable
...
@@ -100,7 +100,7 @@ class ListCollections implements Executable
*/
*/
private
function
executeLegacy
(
Server
$server
)
private
function
executeLegacy
(
Server
$server
)
{
{
$filter
=
empty
(
$this
->
options
[
'filter'
])
?
array
()
:
(
array
)
$this
->
options
[
'filter'
];
$filter
=
empty
(
$this
->
options
[
'filter'
])
?
[]
:
(
array
)
$this
->
options
[
'filter'
];
if
(
array_key_exists
(
'name'
,
$filter
))
{
if
(
array_key_exists
(
'name'
,
$filter
))
{
if
(
!
is_string
(
$filter
[
'name'
]))
{
if
(
!
is_string
(
$filter
[
'name'
]))
{
...
@@ -111,11 +111,11 @@ class ListCollections implements Executable
...
@@ -111,11 +111,11 @@ class ListCollections implements Executable
}
}
$options
=
isset
(
$this
->
options
[
'maxTimeMS'
])
$options
=
isset
(
$this
->
options
[
'maxTimeMS'
])
?
array
(
'modifiers'
=>
array
(
'$maxTimeMS'
=>
$this
->
options
[
'maxTimeMS'
]))
?
[
'modifiers'
=>
[
'$maxTimeMS'
=>
$this
->
options
[
'maxTimeMS'
]]]
:
array
()
;
:
[]
;
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.system.namespaces'
,
new
Query
(
$filter
,
$options
));
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.system.namespaces'
,
new
Query
(
$filter
,
$options
));
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
return
new
CollectionInfoLegacyIterator
(
$cursor
);
return
new
CollectionInfoLegacyIterator
(
$cursor
);
}
}
...
...
src/Operation/ListDatabases.php
View file @
4043b265
...
@@ -30,7 +30,7 @@ class ListDatabases implements Executable
...
@@ -30,7 +30,7 @@ class ListDatabases implements Executable
*
*
* @param array $options Command options
* @param array $options Command options
*/
*/
public
function
__construct
(
array
$options
=
array
()
)
public
function
__construct
(
array
$options
=
[]
)
{
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
...
@@ -48,14 +48,14 @@ class ListDatabases implements Executable
...
@@ -48,14 +48,14 @@ class ListDatabases implements Executable
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$cmd
=
array
(
'listDatabases'
=>
1
)
;
$cmd
=
[
'listDatabases'
=>
1
]
;
if
(
isset
(
$this
->
options
[
'maxTimeMS'
]))
{
if
(
isset
(
$this
->
options
[
'maxTimeMS'
]))
{
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
}
}
$cursor
=
$server
->
executeCommand
(
'admin'
,
new
Command
(
$cmd
));
$cursor
=
$server
->
executeCommand
(
'admin'
,
new
Command
(
$cmd
));
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
$result
=
current
(
$cursor
->
toArray
());
$result
=
current
(
$cursor
->
toArray
());
if
(
empty
(
$result
[
'ok'
]))
{
if
(
empty
(
$result
[
'ok'
]))
{
...
...
src/Operation/ListIndexes.php
View file @
4043b265
...
@@ -39,7 +39,7 @@ class ListIndexes implements Executable
...
@@ -39,7 +39,7 @@ class ListIndexes implements Executable
* @param string $collectionName Collection name
* @param string $collectionName Collection name
* @param array $options Command options
* @param array $options Command options
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
array
$options
=
[]
)
{
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
throw
new
InvalidArgumentTypeException
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
...
@@ -73,7 +73,7 @@ class ListIndexes implements Executable
...
@@ -73,7 +73,7 @@ class ListIndexes implements Executable
*/
*/
private
function
executeCommand
(
Server
$server
)
private
function
executeCommand
(
Server
$server
)
{
{
$cmd
=
array
(
'listIndexes'
=>
$this
->
collectionName
)
;
$cmd
=
[
'listIndexes'
=>
$this
->
collectionName
]
;
if
(
isset
(
$this
->
options
[
'maxTimeMS'
]))
{
if
(
isset
(
$this
->
options
[
'maxTimeMS'
]))
{
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
...
@@ -93,7 +93,7 @@ class ListIndexes implements Executable
...
@@ -93,7 +93,7 @@ class ListIndexes implements Executable
throw
$e
;
throw
$e
;
}
}
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
return
new
IndexInfoIteratorIterator
(
$cursor
);
return
new
IndexInfoIteratorIterator
(
$cursor
);
}
}
...
@@ -107,14 +107,14 @@ class ListIndexes implements Executable
...
@@ -107,14 +107,14 @@ class ListIndexes implements Executable
*/
*/
private
function
executeLegacy
(
Server
$server
)
private
function
executeLegacy
(
Server
$server
)
{
{
$filter
=
array
(
'ns'
=>
$this
->
databaseName
.
'.'
.
$this
->
collectionName
)
;
$filter
=
[
'ns'
=>
$this
->
databaseName
.
'.'
.
$this
->
collectionName
]
;
$options
=
isset
(
$this
->
options
[
'maxTimeMS'
])
$options
=
isset
(
$this
->
options
[
'maxTimeMS'
])
?
array
(
'modifiers'
=>
array
(
'$maxTimeMS'
=>
$this
->
options
[
'maxTimeMS'
]))
?
[
'modifiers'
=>
[
'$maxTimeMS'
=>
$this
->
options
[
'maxTimeMS'
]]]
:
array
()
;
:
[]
;
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.system.indexes'
,
new
Query
(
$filter
,
$options
));
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.system.indexes'
,
new
Query
(
$filter
,
$options
));
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
return
new
IndexInfoIteratorIterator
(
$cursor
);
return
new
IndexInfoIteratorIterator
(
$cursor
);
}
}
...
...
src/Operation/ReplaceOne.php
View file @
4043b265
...
@@ -35,7 +35,7 @@ class ReplaceOne implements Executable
...
@@ -35,7 +35,7 @@ class ReplaceOne implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$replacement
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$replacement
)
&&
!
is_object
(
$replacement
))
{
if
(
!
is_array
(
$replacement
)
&&
!
is_object
(
$replacement
))
{
throw
new
InvalidArgumentTypeException
(
'$replacement'
,
$replacement
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$replacement'
,
$replacement
,
'array or object'
);
...
@@ -50,7 +50,7 @@ class ReplaceOne implements Executable
...
@@ -50,7 +50,7 @@ class ReplaceOne implements Executable
$collectionName
,
$collectionName
,
$filter
,
$filter
,
$replacement
,
$replacement
,
array
(
'multi'
=>
false
)
+
$options
[
'multi'
=>
false
]
+
$options
);
);
}
}
...
...
src/Operation/Update.php
View file @
4043b265
...
@@ -48,7 +48,7 @@ class Update implements Executable
...
@@ -48,7 +48,7 @@ class Update implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
if
(
!
is_array
(
$filter
)
&&
!
is_object
(
$filter
))
{
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$filter'
,
$filter
,
'array or object'
);
...
@@ -58,10 +58,10 @@ class Update implements Executable
...
@@ -58,10 +58,10 @@ class Update implements Executable
throw
new
InvalidArgumentTypeException
(
'$update'
,
$filter
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$update'
,
$filter
,
'array or object'
);
}
}
$options
+=
array
(
$options
+=
[
'multi'
=>
false
,
'multi'
=>
false
,
'upsert'
=>
false
,
'upsert'
=>
false
,
)
;
]
;
if
(
!
is_bool
(
$options
[
'multi'
]))
{
if
(
!
is_bool
(
$options
[
'multi'
]))
{
throw
new
InvalidArgumentTypeException
(
'"multi" option'
,
$options
[
'multi'
],
'boolean'
);
throw
new
InvalidArgumentTypeException
(
'"multi" option'
,
$options
[
'multi'
],
'boolean'
);
...
@@ -95,10 +95,10 @@ class Update implements Executable
...
@@ -95,10 +95,10 @@ class Update implements Executable
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
{
{
$options
=
array
(
$options
=
[
'multi'
=>
$this
->
options
[
'multi'
],
'multi'
=>
$this
->
options
[
'multi'
],
'upsert'
=>
$this
->
options
[
'upsert'
],
'upsert'
=>
$this
->
options
[
'upsert'
],
)
;
]
;
$bulk
=
new
Bulk
();
$bulk
=
new
Bulk
();
$bulk
->
update
(
$this
->
filter
,
$this
->
update
,
$options
);
$bulk
->
update
(
$this
->
filter
,
$this
->
update
,
$options
);
...
...
src/Operation/UpdateMany.php
View file @
4043b265
...
@@ -35,7 +35,7 @@ class UpdateMany implements Executable
...
@@ -35,7 +35,7 @@ class UpdateMany implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
...
@@ -50,7 +50,7 @@ class UpdateMany implements Executable
...
@@ -50,7 +50,7 @@ class UpdateMany implements Executable
$collectionName
,
$collectionName
,
$filter
,
$filter
,
$update
,
$update
,
array
(
'multi'
=>
true
)
+
$options
[
'multi'
=>
true
]
+
$options
);
);
}
}
...
...
src/Operation/UpdateOne.php
View file @
4043b265
...
@@ -35,7 +35,7 @@ class UpdateOne implements Executable
...
@@ -35,7 +35,7 @@ class UpdateOne implements Executable
* @param array $options Command options
* @param array $options Command options
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*/
*/
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
array
()
)
public
function
__construct
(
$databaseName
,
$collectionName
,
$filter
,
$update
,
array
$options
=
[]
)
{
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
if
(
!
is_array
(
$update
)
&&
!
is_object
(
$update
))
{
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
throw
new
InvalidArgumentTypeException
(
'$update'
,
$update
,
'array or object'
);
...
@@ -50,7 +50,7 @@ class UpdateOne implements Executable
...
@@ -50,7 +50,7 @@ class UpdateOne implements Executable
$collectionName
,
$collectionName
,
$filter
,
$filter
,
$update
,
$update
,
array
(
'multi'
=>
false
)
+
$options
[
'multi'
=>
false
]
+
$options
);
);
}
}
...
...
tests/Collection/BulkWriteFunctionalTest.php
View file @
4043b265
...
@@ -17,10 +17,10 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -17,10 +17,10 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
public
function
testInserts
()
public
function
testInserts
()
{
{
$ops
=
array
(
$ops
=
[
array
(
'insertOne'
=>
array
(
array
(
'_id'
=>
1
,
'x'
=>
11
)))
,
[
'insertOne'
=>
[[
'_id'
=>
1
,
'x'
=>
11
]]]
,
array
(
'insertOne'
=>
array
(
array
(
'x'
=>
22
)))
,
[
'insertOne'
=>
[[
'x'
=>
22
]]]
,
)
;
]
;
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
...
@@ -30,10 +30,10 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -30,10 +30,10 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
1
,
$insertedIds
[
0
]);
$this
->
assertSame
(
1
,
$insertedIds
[
0
]);
$this
->
assertInstanceOf
(
'MongoDB\BSON\ObjectId'
,
$insertedIds
[
1
]);
$this
->
assertInstanceOf
(
'MongoDB\BSON\ObjectId'
,
$insertedIds
[
1
]);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
$insertedIds
[
0
],
'x'
=>
11
)
,
[
'_id'
=>
$insertedIds
[
0
],
'x'
=>
11
]
,
array
(
'_id'
=>
$insertedIds
[
1
],
'x'
=>
22
)
,
[
'_id'
=>
$insertedIds
[
1
],
'x'
=>
22
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
@@ -42,13 +42,13 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -42,13 +42,13 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
{
{
$this
->
createFixtures
(
4
);
$this
->
createFixtures
(
4
);
$ops
=
array
(
$ops
=
[
array
(
'updateOne'
=>
array
(
array
(
'_id'
=>
2
),
array
(
'$inc'
=>
array
(
'x'
=>
1
))))
,
[
'updateOne'
=>
[[
'_id'
=>
2
],
[
'$inc'
=>
[
'x'
=>
1
]]]]
,
array
(
'updateMany'
=>
array
(
array
(
'_id'
=>
array
(
'$gt'
=>
2
)),
array
(
'$inc'
=>
array
(
'x'
=>
-
1
))))
,
[
'updateMany'
=>
[[
'_id'
=>
[
'$gt'
=>
2
]],
[
'$inc'
=>
[
'x'
=>
-
1
]]]]
,
array
(
'updateOne'
=>
array
(
array
(
'_id'
=>
5
),
array
(
'$set'
=>
array
(
'x'
=>
55
)),
array
(
'upsert'
=>
true
)))
,
[
'updateOne'
=>
[[
'_id'
=>
5
],
[
'$set'
=>
[
'x'
=>
55
]],
[
'upsert'
=>
true
]]]
,
array
(
'updateOne'
=>
array
(
array
(
'x'
=>
66
),
array
(
'$set'
=>
array
(
'x'
=>
66
)),
array
(
'upsert'
=>
true
)))
,
[
'updateOne'
=>
[[
'x'
=>
66
],
[
'$set'
=>
[
'x'
=>
66
]],
[
'upsert'
=>
true
]]]
,
array
(
'updateMany'
=>
array
(
array
(
'x'
=>
array
(
'$gt'
=>
50
)),
array
(
'$inc'
=>
array
(
'x'
=>
1
))))
,
[
'updateMany'
=>
[[
'x'
=>
[
'$gt'
=>
50
]],
[
'$inc'
=>
[
'x'
=>
1
]]]]
,
)
;
]
;
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
...
@@ -60,14 +60,14 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -60,14 +60,14 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
5
,
$upsertedIds
[
2
]);
$this
->
assertSame
(
5
,
$upsertedIds
[
2
]);
$this
->
assertInstanceOf
(
'MongoDB\BSON\ObjectId'
,
$upsertedIds
[
3
]);
$this
->
assertInstanceOf
(
'MongoDB\BSON\ObjectId'
,
$upsertedIds
[
3
]);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
32
)
,
[
'_id'
=>
3
,
'x'
=>
32
]
,
array
(
'_id'
=>
4
,
'x'
=>
43
)
,
[
'_id'
=>
4
,
'x'
=>
43
]
,
array
(
'_id'
=>
5
,
'x'
=>
56
)
,
[
'_id'
=>
5
,
'x'
=>
56
]
,
array
(
'_id'
=>
$upsertedIds
[
3
],
'x'
=>
67
)
,
[
'_id'
=>
$upsertedIds
[
3
],
'x'
=>
67
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
@@ -76,18 +76,18 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -76,18 +76,18 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
{
{
$this
->
createFixtures
(
4
);
$this
->
createFixtures
(
4
);
$ops
=
array
(
$ops
=
[
array
(
'deleteOne'
=>
array
(
array
(
'_id'
=>
1
)))
,
[
'deleteOne'
=>
[[
'_id'
=>
1
]]]
,
array
(
'deleteMany'
=>
array
(
array
(
'_id'
=>
array
(
'$gt'
=>
2
))))
,
[
'deleteMany'
=>
[[
'_id'
=>
[
'$gt'
=>
2
]]]]
,
)
;
]
;
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
$this
->
assertSame
(
3
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
3
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
@@ -96,32 +96,32 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -96,32 +96,32 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
{
{
$this
->
createFixtures
(
3
);
$this
->
createFixtures
(
3
);
$ops
=
array
(
$ops
=
[
array
(
'updateOne'
=>
array
(
array
(
'_id'
=>
array
(
'$gt'
=>
1
)),
array
(
'$inc'
=>
array
(
'x'
=>
1
))))
,
[
'updateOne'
=>
[[
'_id'
=>
[
'$gt'
=>
1
]],
[
'$inc'
=>
[
'x'
=>
1
]]]]
,
array
(
'updateMany'
=>
array
(
array
(
'_id'
=>
array
(
'$gt'
=>
1
)),
array
(
'$inc'
=>
array
(
'x'
=>
1
))))
,
[
'updateMany'
=>
[[
'_id'
=>
[
'$gt'
=>
1
]],
[
'$inc'
=>
[
'x'
=>
1
]]]]
,
array
(
'insertOne'
=>
array
(
array
(
'_id'
=>
4
,
'x'
=>
44
)))
,
[
'insertOne'
=>
[[
'_id'
=>
4
,
'x'
=>
44
]]]
,
array
(
'deleteMany'
=>
array
(
array
(
'x'
=>
array
(
'$nin'
=>
array
(
24
,
34
)))))
,
[
'deleteMany'
=>
[[
'x'
=>
[
'$nin'
=>
[
24
,
34
]]]]]
,
array
(
'replaceOne'
=>
array
(
array
(
'_id'
=>
4
),
array
(
'_id'
=>
4
,
'x'
=>
44
),
array
(
'upsert'
=>
true
)))
,
[
'replaceOne'
=>
[[
'_id'
=>
4
],
[
'_id'
=>
4
,
'x'
=>
44
],
[
'upsert'
=>
true
]]]
,
)
;
]
;
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$result
=
$this
->
collection
->
bulkWrite
(
$ops
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
$this
->
assertInstanceOf
(
'MongoDB\BulkWriteResult'
,
$result
);
$this
->
assertSame
(
1
,
$result
->
getInsertedCount
());
$this
->
assertSame
(
1
,
$result
->
getInsertedCount
());
$this
->
assertSame
(
array
(
2
=>
4
)
,
$result
->
getInsertedIds
());
$this
->
assertSame
(
[
2
=>
4
]
,
$result
->
getInsertedIds
());
$this
->
assertSame
(
3
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
3
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
3
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
3
,
$result
->
getModifiedCount
());
$this
->
assertSame
(
1
,
$result
->
getUpsertedCount
());
$this
->
assertSame
(
1
,
$result
->
getUpsertedCount
());
$this
->
assertSame
(
array
(
4
=>
4
)
,
$result
->
getUpsertedIds
());
$this
->
assertSame
(
[
4
=>
4
]
,
$result
->
getUpsertedIds
());
$this
->
assertSame
(
2
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
2
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
2
,
'x'
=>
24
)
,
[
'_id'
=>
2
,
'x'
=>
24
]
,
array
(
'_id'
=>
3
,
'x'
=>
34
)
,
[
'_id'
=>
3
,
'x'
=>
34
]
,
array
(
'_id'
=>
4
,
'x'
=>
44
)
,
[
'_id'
=>
4
,
'x'
=>
44
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
@@ -132,9 +132,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -132,9 +132,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testUnknownOperation
()
public
function
testUnknownOperation
()
{
{
$this
->
collection
->
bulkWrite
(
array
(
$this
->
collection
->
bulkWrite
(
[
array
(
'foo'
=>
array
(
array
(
'_id'
=>
1
)))
,
[
'foo'
=>
[[
'_id'
=>
1
]]]
,
)
);
]
);
}
}
/**
/**
...
@@ -149,17 +149,17 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -149,17 +149,17 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
public
function
provideOpsWithMissingArguments
()
public
function
provideOpsWithMissingArguments
()
{
{
return
array
(
return
[
array
(
array
(
array
(
'insertOne'
=>
array
())))
,
[[[
'insertOne'
=>
[]]]]
,
array
(
array
(
array
(
'updateOne'
=>
array
())))
,
[[[
'updateOne'
=>
[]]]]
,
array
(
array
(
array
(
'updateOne'
=>
array
(
array
(
'_id'
=>
1
)))))
,
[[[
'updateOne'
=>
[[
'_id'
=>
1
]]]]]
,
array
(
array
(
array
(
'updateMany'
=>
array
())))
,
[[[
'updateMany'
=>
[]]]]
,
array
(
array
(
array
(
'updateMany'
=>
array
(
array
(
'_id'
=>
1
)))))
,
[[[
'updateMany'
=>
[[
'_id'
=>
1
]]]]]
,
array
(
array
(
array
(
'replaceOne'
=>
array
())))
,
[[[
'replaceOne'
=>
[]]]]
,
array
(
array
(
array
(
'replaceOne'
=>
array
(
array
(
'_id'
=>
1
)))))
,
[[[
'replaceOne'
=>
[[
'_id'
=>
1
]]]]]
,
array
(
array
(
array
(
'deleteOne'
=>
array
())))
,
[[[
'deleteOne'
=>
[]]]]
,
array
(
array
(
array
(
'deleteMany'
=>
array
())))
,
[[[
'deleteMany'
=>
[]]]]
,
)
;
]
;
}
}
/**
/**
...
@@ -168,9 +168,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -168,9 +168,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testUpdateOneRequiresUpdateOperators
()
public
function
testUpdateOneRequiresUpdateOperators
()
{
{
$this
->
collection
->
bulkWrite
(
array
(
$this
->
collection
->
bulkWrite
(
[
array
(
'updateOne'
=>
array
(
array
(
'_id'
=>
1
),
array
(
'x'
=>
1
)))
,
[
'updateOne'
=>
[[
'_id'
=>
1
],
[
'x'
=>
1
]]]
,
)
);
]
);
}
}
/**
/**
...
@@ -179,9 +179,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -179,9 +179,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testUpdateManyRequiresUpdateOperators
()
public
function
testUpdateManyRequiresUpdateOperators
()
{
{
$this
->
collection
->
bulkWrite
(
array
(
$this
->
collection
->
bulkWrite
(
[
array
(
'updateMany'
=>
array
(
array
(
'_id'
=>
array
(
'$gt'
=>
1
)),
array
(
'x'
=>
1
)))
,
[
'updateMany'
=>
[[
'_id'
=>
[
'$gt'
=>
1
]],
[
'x'
=>
1
]]]
,
)
);
]
);
}
}
/**
/**
...
@@ -190,9 +190,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -190,9 +190,9 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testReplaceOneRequiresReplacementDocument
()
public
function
testReplaceOneRequiresReplacementDocument
()
{
{
$this
->
collection
->
bulkWrite
(
array
(
$this
->
collection
->
bulkWrite
(
[
array
(
'replaceOne'
=>
array
(
array
(
'_id'
=>
1
),
array
(
'$inc'
=>
array
(
'x'
=>
1
))))
,
[
'replaceOne'
=>
[[
'_id'
=>
1
],
[
'$inc'
=>
[
'x'
=>
1
]]]]
,
)
);
]
);
}
}
/**
/**
...
@@ -205,10 +205,10 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -205,10 +205,10 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
$bulkWrite
=
new
BulkWrite
([
'ordered'
=>
true
]);
$bulkWrite
=
new
BulkWrite
([
'ordered'
=>
true
]);
for
(
$i
=
1
;
$i
<=
$n
;
$i
++
)
{
for
(
$i
=
1
;
$i
<=
$n
;
$i
++
)
{
$bulkWrite
->
insert
(
array
(
$bulkWrite
->
insert
(
[
'_id'
=>
$i
,
'_id'
=>
$i
,
'x'
=>
(
integer
)
(
$i
.
$i
),
'x'
=>
(
integer
)
(
$i
.
$i
),
)
);
]
);
}
}
$result
=
$this
->
manager
->
executeBulkWrite
(
$this
->
getNamespace
(),
$bulkWrite
);
$result
=
$this
->
manager
->
executeBulkWrite
(
$this
->
getNamespace
(),
$bulkWrite
);
...
...
tests/Collection/CollectionFunctionalTest.php
View file @
4043b265
...
@@ -22,13 +22,13 @@ class CollectionFunctionalTest extends FunctionalTestCase
...
@@ -22,13 +22,13 @@ class CollectionFunctionalTest extends FunctionalTestCase
public
function
provideInvalidNamespaceValues
()
public
function
provideInvalidNamespaceValues
()
{
{
return
array
(
return
[
array
(
null
)
,
[
null
]
,
array
(
''
)
,
[
''
]
,
array
(
'db_collection'
)
,
[
'db_collection'
]
,
array
(
'db'
)
,
[
'db'
]
,
array
(
'.collection'
)
,
[
'.collection'
]
,
)
;
]
;
}
}
public
function
testToString
()
public
function
testToString
()
...
@@ -53,7 +53,7 @@ class CollectionFunctionalTest extends FunctionalTestCase
...
@@ -53,7 +53,7 @@ class CollectionFunctionalTest extends FunctionalTestCase
public
function
testDrop
()
public
function
testDrop
()
{
{
$writeResult
=
$this
->
collection
->
insertOne
(
array
(
'x'
=>
1
)
);
$writeResult
=
$this
->
collection
->
insertOne
(
[
'x'
=>
1
]
);
$this
->
assertEquals
(
1
,
$writeResult
->
getInsertedCount
());
$this
->
assertEquals
(
1
,
$writeResult
->
getInsertedCount
());
$commandResult
=
$this
->
collection
->
drop
();
$commandResult
=
$this
->
collection
->
drop
();
...
@@ -65,13 +65,13 @@ class CollectionFunctionalTest extends FunctionalTestCase
...
@@ -65,13 +65,13 @@ class CollectionFunctionalTest extends FunctionalTestCase
{
{
$this
->
createFixtures
(
5
);
$this
->
createFixtures
(
5
);
$filter
=
array
(
'_id'
=>
array
(
'$lt'
=>
5
))
;
$filter
=
[
'_id'
=>
[
'$lt'
=>
5
]]
;
$options
=
array
(
$options
=
[
'skip'
=>
1
,
'skip'
=>
1
,
'sort'
=>
array
(
'x'
=>
-
1
)
,
'sort'
=>
[
'x'
=>
-
1
]
,
)
;
]
;
$expected
=
(
object
)
array
(
'_id'
=>
3
,
'x'
=>
33
)
;
$expected
=
(
object
)
[
'_id'
=>
3
,
'x'
=>
33
]
;
$this
->
assertEquals
(
$expected
,
$this
->
collection
->
findOne
(
$filter
,
$options
));
$this
->
assertEquals
(
$expected
,
$this
->
collection
->
findOne
(
$filter
,
$options
));
}
}
...
@@ -86,10 +86,10 @@ class CollectionFunctionalTest extends FunctionalTestCase
...
@@ -86,10 +86,10 @@ class CollectionFunctionalTest extends FunctionalTestCase
$bulkWrite
=
new
BulkWrite
([
'ordered'
=>
true
]);
$bulkWrite
=
new
BulkWrite
([
'ordered'
=>
true
]);
for
(
$i
=
1
;
$i
<=
$n
;
$i
++
)
{
for
(
$i
=
1
;
$i
<=
$n
;
$i
++
)
{
$bulkWrite
->
insert
(
array
(
$bulkWrite
->
insert
(
[
'_id'
=>
$i
,
'_id'
=>
$i
,
'x'
=>
(
integer
)
(
$i
.
$i
),
'x'
=>
(
integer
)
(
$i
.
$i
),
)
);
]
);
}
}
$result
=
$this
->
manager
->
executeBulkWrite
(
$this
->
getNamespace
(),
$bulkWrite
);
$result
=
$this
->
manager
->
executeBulkWrite
(
$this
->
getNamespace
(),
$bulkWrite
);
...
...
tests/Collection/CrudSpec/AggregateFunctionalTest.php
View file @
4043b265
...
@@ -25,17 +25,17 @@ class AggregateFunctionalTest extends FunctionalTestCase
...
@@ -25,17 +25,17 @@ class AggregateFunctionalTest extends FunctionalTestCase
public
function
testAggregateWithMultipleStages
()
public
function
testAggregateWithMultipleStages
()
{
{
$cursor
=
$this
->
collection
->
aggregate
(
$cursor
=
$this
->
collection
->
aggregate
(
array
(
[
array
(
'$sort'
=>
array
(
'x'
=>
1
))
,
[
'$sort'
=>
[
'x'
=>
1
]]
,
array
(
'$match'
=>
array
(
'_id'
=>
array
(
'$gt'
=>
1
)))
,
[
'$match'
=>
[
'_id'
=>
[
'$gt'
=>
1
]]]
,
)
,
]
,
array
(
'batchSize'
=>
2
)
[
'batchSize'
=>
2
]
);
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$cursor
);
$this
->
assertSameDocuments
(
$expected
,
$cursor
);
}
}
...
@@ -53,17 +53,17 @@ class AggregateFunctionalTest extends FunctionalTestCase
...
@@ -53,17 +53,17 @@ class AggregateFunctionalTest extends FunctionalTestCase
$operation
->
execute
(
$this
->
getPrimaryServer
());
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
collection
->
aggregate
(
$this
->
collection
->
aggregate
(
array
(
[
array
(
'$sort'
=>
array
(
'x'
=>
1
))
,
[
'$sort'
=>
[
'x'
=>
1
]]
,
array
(
'$match'
=>
array
(
'_id'
=>
array
(
'$gt'
=>
1
)))
,
[
'$match'
=>
[
'_id'
=>
[
'$gt'
=>
1
]]]
,
array
(
'$out'
=>
$outputCollection
->
getCollectionName
())
,
[
'$out'
=>
$outputCollection
->
getCollectionName
()]
,
)
]
);
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$outputCollection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$outputCollection
->
find
());
...
...
tests/Collection/CrudSpec/CountFunctionalTest.php
View file @
4043b265
...
@@ -23,15 +23,15 @@ class CountFunctionalTest extends FunctionalTestCase
...
@@ -23,15 +23,15 @@ class CountFunctionalTest extends FunctionalTestCase
public
function
testCountWithFilter
()
public
function
testCountWithFilter
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$this
->
assertSame
(
2
,
$this
->
collection
->
count
(
$filter
));
$this
->
assertSame
(
2
,
$this
->
collection
->
count
(
$filter
));
}
}
public
function
testCountWithSkipAndLimit
()
public
function
testCountWithSkipAndLimit
()
{
{
$filter
=
array
()
;
$filter
=
[]
;
$options
=
array
(
'skip'
=>
1
,
'limit'
=>
3
)
;
$options
=
[
'skip'
=>
1
,
'limit'
=>
3
]
;
$this
->
assertSame
(
2
,
$this
->
collection
->
count
(
$filter
,
$options
));
$this
->
assertSame
(
2
,
$this
->
collection
->
count
(
$filter
,
$options
));
}
}
...
...
tests/Collection/CrudSpec/DeleteManyFunctionalTest.php
View file @
4043b265
...
@@ -18,30 +18,30 @@ class DeleteManyFunctionalTest extends FunctionalTestCase
...
@@ -18,30 +18,30 @@ class DeleteManyFunctionalTest extends FunctionalTestCase
public
function
testDeleteManyWhenManyDocumentsMatch
()
public
function
testDeleteManyWhenManyDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$result
=
$this
->
collection
->
deleteMany
(
$filter
);
$result
=
$this
->
collection
->
deleteMany
(
$filter
);
$this
->
assertSame
(
2
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
2
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testDeleteManyWhenNoDocumentsMatch
()
public
function
testDeleteManyWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$result
=
$this
->
collection
->
deleteMany
(
$filter
);
$result
=
$this
->
collection
->
deleteMany
(
$filter
);
$this
->
assertSame
(
0
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
0
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/DeleteOneFunctionalTest.php
View file @
4043b265
...
@@ -18,46 +18,46 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
...
@@ -18,46 +18,46 @@ class DeleteOneFunctionalTest extends FunctionalTestCase
public
function
testDeleteOneWhenManyDocumentsMatch
()
public
function
testDeleteOneWhenManyDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$result
=
$this
->
collection
->
deleteOne
(
$filter
);
$result
=
$this
->
collection
->
deleteOne
(
$filter
);
$this
->
assertSame
(
1
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
1
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testDeleteOneWhenOneDocumentMatches
()
public
function
testDeleteOneWhenOneDocumentMatches
()
{
{
$filter
=
array
(
'_id'
=>
2
)
;
$filter
=
[
'_id'
=>
2
]
;
$result
=
$this
->
collection
->
deleteOne
(
$filter
);
$result
=
$this
->
collection
->
deleteOne
(
$filter
);
$this
->
assertSame
(
1
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
1
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testDeleteOneWhenNoDocumentsMatch
()
public
function
testDeleteOneWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$result
=
$this
->
collection
->
deleteOne
(
$filter
);
$result
=
$this
->
collection
->
deleteOne
(
$filter
);
$this
->
assertSame
(
0
,
$result
->
getDeletedCount
());
$this
->
assertSame
(
0
,
$result
->
getDeletedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/DistinctFunctionalTest.php
View file @
4043b265
...
@@ -18,13 +18,13 @@ class DistinctFunctionalTest extends FunctionalTestCase
...
@@ -18,13 +18,13 @@ class DistinctFunctionalTest extends FunctionalTestCase
public
function
testDistinctWithoutFilter
()
public
function
testDistinctWithoutFilter
()
{
{
$this
->
assertSame
(
array
(
11
,
22
,
33
)
,
$this
->
collection
->
distinct
(
'x'
));
$this
->
assertSame
(
[
11
,
22
,
33
]
,
$this
->
collection
->
distinct
(
'x'
));
}
}
public
function
testDistinctWithFilter
()
public
function
testDistinctWithFilter
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$this
->
assertSame
(
array
(
22
,
33
)
,
$this
->
collection
->
distinct
(
'x'
,
$filter
));
$this
->
assertSame
(
[
22
,
33
]
,
$this
->
collection
->
distinct
(
'x'
,
$filter
));
}
}
}
}
tests/Collection/CrudSpec/FindFunctionalTest.php
View file @
4043b265
...
@@ -18,46 +18,46 @@ class FindFunctionalTest extends FunctionalTestCase
...
@@ -18,46 +18,46 @@ class FindFunctionalTest extends FunctionalTestCase
public
function
testFindWithFilter
()
public
function
testFindWithFilter
()
{
{
$filter
=
array
(
'_id'
=>
1
)
;
$filter
=
[
'_id'
=>
1
]
;
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
(
$filter
));
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
(
$filter
));
}
}
public
function
testFindWithFilterSortSkipAndLimit
()
public
function
testFindWithFilterSortSkipAndLimit
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
2
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
2
]]
;
$options
=
array
(
$options
=
[
'sort'
=>
array
(
'_id'
=>
1
)
,
'sort'
=>
[
'_id'
=>
1
]
,
'skip'
=>
2
,
'skip'
=>
2
,
'limit'
=>
2
,
'limit'
=>
2
,
)
;
]
;
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
5
,
'x'
=>
55
)
,
[
'_id'
=>
5
,
'x'
=>
55
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
(
$filter
,
$options
));
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
(
$filter
,
$options
));
}
}
public
function
testFindWithLimitSortAndBatchSize
()
public
function
testFindWithLimitSortAndBatchSize
()
{
{
$filter
=
array
()
;
$filter
=
[]
;
$options
=
array
(
$options
=
[
'sort'
=>
array
(
'_id'
=>
1
)
,
'sort'
=>
[
'_id'
=>
1
]
,
'limit'
=>
4
,
'limit'
=>
4
,
'batchSize'
=>
2
,
'batchSize'
=>
2
,
)
;
]
;
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
44
)
,
[
'_id'
=>
4
,
'x'
=>
44
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
(
$filter
,
$options
));
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
(
$filter
,
$options
));
}
}
...
...
tests/Collection/CrudSpec/FindOneAndDeleteFunctionalTest.php
View file @
4043b265
...
@@ -18,58 +18,58 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
...
@@ -18,58 +18,58 @@ class FindOneAndDeleteFunctionalTest extends FunctionalTestCase
public
function
testFindOneAndDeleteWhenManyDocumentsMatch
()
public
function
testFindOneAndDeleteWhenManyDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndDelete
(
$filter
,
$options
);
$document
=
$this
->
collection
->
findOneAndDelete
(
$filter
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
22
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
22
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndDeleteWhenOneDocumentMatches
()
public
function
testFindOneAndDeleteWhenOneDocumentMatches
()
{
{
$filter
=
array
(
'_id'
=>
2
)
;
$filter
=
[
'_id'
=>
2
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndDelete
(
$filter
,
$options
);
$document
=
$this
->
collection
->
findOneAndDelete
(
$filter
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
22
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
22
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndDeleteWhenNoDocumentsMatch
()
public
function
testFindOneAndDeleteWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndDelete
(
$filter
,
$options
);
$document
=
$this
->
collection
->
findOneAndDelete
(
$filter
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/FindOneAndReplaceFunctionalTest.php
View file @
4043b265
...
@@ -21,178 +21,178 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
...
@@ -21,178 +21,178 @@ class FindOneAndReplaceFunctionalTest extends FunctionalTestCase
public
function
testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentBeforeModification
()
public
function
testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$replacement
=
array
(
'x'
=>
32
)
;
$replacement
=
[
'x'
=>
32
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
22
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
22
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
32
)
,
[
'_id'
=>
2
,
'x'
=>
32
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfterModification
()
public
function
testFindOneAndReplaceWhenManyDocumentsMatchReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$replacement
=
array
(
'x'
=>
32
)
;
$replacement
=
[
'x'
=>
32
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
32
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
32
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
32
)
,
[
'_id'
=>
2
,
'x'
=>
32
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBeforeModification
()
public
function
testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
2
)
;
$filter
=
[
'_id'
=>
2
]
;
$replacement
=
array
(
'x'
=>
32
)
;
$replacement
=
[
'x'
=>
32
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
22
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
22
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
32
)
,
[
'_id'
=>
2
,
'x'
=>
32
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfterModification
()
public
function
testFindOneAndReplaceWhenOneDocumentMatchesReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
2
)
;
$filter
=
[
'_id'
=>
2
]
;
$replacement
=
array
(
'x'
=>
32
)
;
$replacement
=
[
'x'
=>
32
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
32
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
32
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
32
)
,
[
'_id'
=>
2
,
'x'
=>
32
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBeforeModification
()
public
function
testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$replacement
=
array
(
'x'
=>
44
)
;
$replacement
=
[
'x'
=>
44
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification
()
public
function
testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
$replacement
=
array
(
'_id'
=>
4
,
'x'
=>
44
)
;
$replacement
=
[
'_id'
=>
4
,
'x'
=>
44
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'upsert'
=>
true
,
'upsert'
=>
true
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
44
)
,
[
'_id'
=>
4
,
'x'
=>
44
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterModification
()
public
function
testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$replacement
=
array
(
'x'
=>
44
)
;
$replacement
=
[
'x'
=>
44
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification
()
public
function
testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
$replacement
=
array
(
'_id'
=>
4
,
'x'
=>
44
)
;
$replacement
=
[
'_id'
=>
4
,
'x'
=>
44
]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndReplace
::
RETURN_DOCUMENT_AFTER
,
'upsert'
=>
true
,
'upsert'
=>
true
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$document
=
$this
->
collection
->
findOneAndReplace
(
$filter
,
$replacement
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
44
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
44
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
44
)
,
[
'_id'
=>
4
,
'x'
=>
44
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/FindOneAndUpdateFunctionalTest.php
View file @
4043b265
...
@@ -21,176 +21,176 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
...
@@ -21,176 +21,176 @@ class FindOneAndUpdateFunctionalTest extends FunctionalTestCase
public
function
testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentBeforeModification
()
public
function
testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
22
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
22
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfterModification
()
public
function
testFindOneAndUpdateWhenManyDocumentsMatchReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
23
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
23
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBeforeModification
()
public
function
testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
2
)
;
$filter
=
[
'_id'
=>
2
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
22
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
22
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfterModification
()
public
function
testFindOneAndUpdateWhenOneDocumentMatchesReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
2
)
;
$filter
=
[
'_id'
=>
2
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
23
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
23
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeModification
()
public
function
testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification
()
public
function
testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'upsert'
=>
true
,
'upsert'
=>
true
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
1
)
,
[
'_id'
=>
4
,
'x'
=>
1
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterModification
()
public
function
testFindOneAndUpdateWhenNoDocumentsMatchReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertNull
(
$document
);
$this
->
assertNull
(
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification
()
public
function
testFindOneAndUpdateWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
$options
=
[
'projection'
=>
array
(
'x'
=>
1
,
'_id'
=>
0
)
,
'projection'
=>
[
'x'
=>
1
,
'_id'
=>
0
]
,
'sort'
=>
array
(
'x'
=>
1
)
,
'sort'
=>
[
'x'
=>
1
]
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
'returnDocument'
=>
FindOneAndUpdate
::
RETURN_DOCUMENT_AFTER
,
'upsert'
=>
true
,
'upsert'
=>
true
,
)
;
]
;
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$document
=
$this
->
collection
->
findOneAndUpdate
(
$filter
,
$update
,
$options
);
$this
->
assertSameDocument
(
array
(
'x'
=>
1
)
,
$document
);
$this
->
assertSameDocument
(
[
'x'
=>
1
]
,
$document
);
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
1
)
,
[
'_id'
=>
4
,
'x'
=>
1
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/FunctionalTestCase.php
View file @
4043b265
...
@@ -20,10 +20,10 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
...
@@ -20,10 +20,10 @@ abstract class FunctionalTestCase extends BaseFunctionalTestCase
$bulkWrite
=
new
BulkWrite
([
'ordered'
=>
true
]);
$bulkWrite
=
new
BulkWrite
([
'ordered'
=>
true
]);
for
(
$i
=
1
;
$i
<=
$n
;
$i
++
)
{
for
(
$i
=
1
;
$i
<=
$n
;
$i
++
)
{
$bulkWrite
->
insert
(
array
(
$bulkWrite
->
insert
(
[
'_id'
=>
$i
,
'_id'
=>
$i
,
'x'
=>
(
integer
)
(
$i
.
$i
),
'x'
=>
(
integer
)
(
$i
.
$i
),
)
);
]
);
}
}
$result
=
$this
->
manager
->
executeBulkWrite
(
$this
->
getNamespace
(),
$bulkWrite
);
$result
=
$this
->
manager
->
executeBulkWrite
(
$this
->
getNamespace
(),
$bulkWrite
);
...
...
tests/Collection/CrudSpec/InsertManyFunctionalTest.php
View file @
4043b265
...
@@ -18,20 +18,20 @@ class InsertManyFunctionalTest extends FunctionalTestCase
...
@@ -18,20 +18,20 @@ class InsertManyFunctionalTest extends FunctionalTestCase
public
function
testInsertManyWithNonexistentDocuments
()
public
function
testInsertManyWithNonexistentDocuments
()
{
{
$documents
=
array
(
$documents
=
[
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$result
=
$this
->
collection
->
insertMany
(
$documents
);
$result
=
$this
->
collection
->
insertMany
(
$documents
);
$this
->
assertSame
(
2
,
$result
->
getInsertedCount
());
$this
->
assertSame
(
2
,
$result
->
getInsertedCount
());
$this
->
assertSame
(
array
(
2
,
3
)
,
$result
->
getInsertedIds
());
$this
->
assertSame
(
[
2
,
3
]
,
$result
->
getInsertedIds
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/InsertOneFunctionalTest.php
View file @
4043b265
...
@@ -18,16 +18,16 @@ class InsertOneFunctionalTest extends FunctionalTestCase
...
@@ -18,16 +18,16 @@ class InsertOneFunctionalTest extends FunctionalTestCase
public
function
testInsertOneWithANonexistentDocument
()
public
function
testInsertOneWithANonexistentDocument
()
{
{
$document
=
array
(
'_id'
=>
2
,
'x'
=>
22
)
;
$document
=
[
'_id'
=>
2
,
'x'
=>
22
]
;
$result
=
$this
->
collection
->
insertOne
(
$document
);
$result
=
$this
->
collection
->
insertOne
(
$document
);
$this
->
assertSame
(
1
,
$result
->
getInsertedCount
());
$this
->
assertSame
(
1
,
$result
->
getInsertedCount
());
$this
->
assertSame
(
2
,
$result
->
getInsertedId
());
$this
->
assertSame
(
2
,
$result
->
getInsertedId
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/ReplaceOneFunctionalTest.php
View file @
4043b265
...
@@ -22,97 +22,97 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
...
@@ -22,97 +22,97 @@ class ReplaceOneFunctionalTest extends FunctionalTestCase
public
function
testReplaceOneWhenManyDocumentsMatch
()
public
function
testReplaceOneWhenManyDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$replacement
=
array
(
'x'
=>
111
)
;
$replacement
=
[
'x'
=>
111
]
;
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
);
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
);
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
111
)
,
[
'_id'
=>
2
,
'x'
=>
111
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testReplaceOneWhenOneDocumentMatches
()
public
function
testReplaceOneWhenOneDocumentMatches
()
{
{
$filter
=
array
(
'_id'
=>
1
)
;
$filter
=
[
'_id'
=>
1
]
;
$replacement
=
array
(
'x'
=>
111
)
;
$replacement
=
[
'x'
=>
111
]
;
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
);
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
);
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
111
)
,
[
'_id'
=>
1
,
'x'
=>
111
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testReplaceOneWhenNoDocumentsMatch
()
public
function
testReplaceOneWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$replacement
=
array
(
'x'
=>
111
)
;
$replacement
=
[
'x'
=>
111
]
;
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
);
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified
()
public
function
testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$replacement
=
array
(
'_id'
=>
4
,
'x'
=>
1
)
;
$replacement
=
[
'_id'
=>
4
,
'x'
=>
1
]
;
$options
=
array
(
'upsert'
=>
true
)
;
$options
=
[
'upsert'
=>
true
]
;
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
,
$options
);
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
,
$options
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
1
)
,
[
'_id'
=>
4
,
'x'
=>
1
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified
()
public
function
testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
$replacement
=
array
(
'_id'
=>
4
,
'x'
=>
1
)
;
$replacement
=
[
'_id'
=>
4
,
'x'
=>
1
]
;
$options
=
array
(
'upsert'
=>
true
)
;
$options
=
[
'upsert'
=>
true
]
;
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
,
$options
);
$result
=
$this
->
collection
->
replaceOne
(
$filter
,
$replacement
,
$options
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
1
)
,
[
'_id'
=>
4
,
'x'
=>
1
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/UpdateManyFunctionalTest.php
View file @
4043b265
...
@@ -22,75 +22,75 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
...
@@ -22,75 +22,75 @@ class UpdateManyFunctionalTest extends FunctionalTestCase
public
function
testUpdateManyWhenManyDocumentsMatch
()
public
function
testUpdateManyWhenManyDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
);
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
);
$this
->
assertSame
(
2
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
2
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
2
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
2
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
34
)
,
[
'_id'
=>
3
,
'x'
=>
34
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testUpdateManyWhenOneDocumentMatches
()
public
function
testUpdateManyWhenOneDocumentMatches
()
{
{
$filter
=
array
(
'_id'
=>
1
)
;
$filter
=
[
'_id'
=>
1
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
);
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
);
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
12
)
,
[
'_id'
=>
1
,
'x'
=>
12
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testUpdateManyWhenNoDocumentsMatch
()
public
function
testUpdateManyWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
);
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testUpdateManyWithUpsertWhenNoDocumentsMatch
()
public
function
testUpdateManyWithUpsertWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
'upsert'
=>
true
)
;
$options
=
[
'upsert'
=>
true
]
;
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
,
$options
);
$result
=
$this
->
collection
->
updateMany
(
$filter
,
$update
,
$options
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
1
)
,
[
'_id'
=>
4
,
'x'
=>
1
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/CrudSpec/UpdateOneFunctionalTest.php
View file @
4043b265
...
@@ -22,75 +22,75 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
...
@@ -22,75 +22,75 @@ class UpdateOneFunctionalTest extends FunctionalTestCase
public
function
testUpdateOneWhenManyDocumentsMatch
()
public
function
testUpdateOneWhenManyDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
array
(
'$gt'
=>
1
))
;
$filter
=
[
'_id'
=>
[
'$gt'
=>
1
]]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
);
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
);
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
23
)
,
[
'_id'
=>
2
,
'x'
=>
23
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testUpdateOneWhenOneDocumentMatches
()
public
function
testUpdateOneWhenOneDocumentMatches
()
{
{
$filter
=
array
(
'_id'
=>
1
)
;
$filter
=
[
'_id'
=>
1
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
);
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
);
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
1
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
1
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
12
)
,
[
'_id'
=>
1
,
'x'
=>
12
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testUpdateOneWhenNoDocumentsMatch
()
public
function
testUpdateOneWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
);
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
public
function
testUpdateOneWithUpsertWhenNoDocumentsMatch
()
public
function
testUpdateOneWithUpsertWhenNoDocumentsMatch
()
{
{
$filter
=
array
(
'_id'
=>
4
)
;
$filter
=
[
'_id'
=>
4
]
;
$update
=
array
(
'$inc'
=>
array
(
'x'
=>
1
))
;
$update
=
[
'$inc'
=>
[
'x'
=>
1
]]
;
$options
=
array
(
'upsert'
=>
true
)
;
$options
=
[
'upsert'
=>
true
]
;
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
,
$options
);
$result
=
$this
->
collection
->
updateOne
(
$filter
,
$update
,
$options
);
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
0
,
$result
->
getMatchedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
omitModifiedCount
or
$this
->
assertSame
(
0
,
$result
->
getModifiedCount
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$this
->
assertSame
(
4
,
$result
->
getUpsertedId
());
$expected
=
array
(
$expected
=
[
array
(
'_id'
=>
1
,
'x'
=>
11
)
,
[
'_id'
=>
1
,
'x'
=>
11
]
,
array
(
'_id'
=>
2
,
'x'
=>
22
)
,
[
'_id'
=>
2
,
'x'
=>
22
]
,
array
(
'_id'
=>
3
,
'x'
=>
33
)
,
[
'_id'
=>
3
,
'x'
=>
33
]
,
array
(
'_id'
=>
4
,
'x'
=>
1
)
,
[
'_id'
=>
4
,
'x'
=>
1
]
,
)
;
]
;
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
}
...
...
tests/Collection/IndexManagementFunctionalTest.php
View file @
4043b265
...
@@ -16,28 +16,28 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
...
@@ -16,28 +16,28 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
{
{
$that
=
$this
;
$that
=
$this
;
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
array
(
'x'
=>
1
),
array
(
'sparse'
=>
true
,
'unique'
=>
true
)
));
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
[
'x'
=>
1
],
[
'sparse'
=>
true
,
'unique'
=>
true
]
));
$this
->
assertIndexExists
(
'x_1'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$this
->
assertIndexExists
(
'x_1'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$that
->
assertTrue
(
$info
->
isSparse
());
$that
->
assertTrue
(
$info
->
isSparse
());
$that
->
assertTrue
(
$info
->
isUnique
());
$that
->
assertTrue
(
$info
->
isUnique
());
$that
->
assertFalse
(
$info
->
isTtl
());
$that
->
assertFalse
(
$info
->
isTtl
());
});
});
$this
->
assertSame
(
'y_-1_z_1'
,
$this
->
collection
->
createIndex
(
array
(
'y'
=>
-
1
,
'z'
=>
1
)
));
$this
->
assertSame
(
'y_-1_z_1'
,
$this
->
collection
->
createIndex
(
[
'y'
=>
-
1
,
'z'
=>
1
]
));
$this
->
assertIndexExists
(
'y_-1_z_1'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$this
->
assertIndexExists
(
'y_-1_z_1'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$that
->
assertFalse
(
$info
->
isSparse
());
$that
->
assertFalse
(
$info
->
isSparse
());
$that
->
assertFalse
(
$info
->
isUnique
());
$that
->
assertFalse
(
$info
->
isUnique
());
$that
->
assertFalse
(
$info
->
isTtl
());
$that
->
assertFalse
(
$info
->
isTtl
());
});
});
$this
->
assertSame
(
'g_2dsphere_z_1'
,
$this
->
collection
->
createIndex
(
array
(
'g'
=>
'2dsphere'
,
'z'
=>
1
)
));
$this
->
assertSame
(
'g_2dsphere_z_1'
,
$this
->
collection
->
createIndex
(
[
'g'
=>
'2dsphere'
,
'z'
=>
1
]
));
$this
->
assertIndexExists
(
'g_2dsphere_z_1'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$this
->
assertIndexExists
(
'g_2dsphere_z_1'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$that
->
assertFalse
(
$info
->
isSparse
());
$that
->
assertFalse
(
$info
->
isSparse
());
$that
->
assertFalse
(
$info
->
isUnique
());
$that
->
assertFalse
(
$info
->
isUnique
());
$that
->
assertFalse
(
$info
->
isTtl
());
$that
->
assertFalse
(
$info
->
isTtl
());
});
});
$this
->
assertSame
(
'my_ttl'
,
$this
->
collection
->
createIndex
(
array
(
't'
=>
1
),
array
(
'expireAfterSeconds'
=>
0
,
'name'
=>
'my_ttl'
)
));
$this
->
assertSame
(
'my_ttl'
,
$this
->
collection
->
createIndex
(
[
't'
=>
1
],
[
'expireAfterSeconds'
=>
0
,
'name'
=>
'my_ttl'
]
));
$this
->
assertIndexExists
(
'my_ttl'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$this
->
assertIndexExists
(
'my_ttl'
,
function
(
IndexInfo
$info
)
use
(
$that
)
{
$that
->
assertFalse
(
$info
->
isSparse
());
$that
->
assertFalse
(
$info
->
isSparse
());
$that
->
assertFalse
(
$info
->
isUnique
());
$that
->
assertFalse
(
$info
->
isUnique
());
...
@@ -49,14 +49,14 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
...
@@ -49,14 +49,14 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
{
{
$that
=
$this
;
$that
=
$this
;
$expectedNames
=
array
(
'x_1'
,
'y_-1_z_1'
,
'g_2dsphere_z_1'
,
'my_ttl'
)
;
$expectedNames
=
[
'x_1'
,
'y_-1_z_1'
,
'g_2dsphere_z_1'
,
'my_ttl'
]
;
$indexes
=
array
(
$indexes
=
[
array
(
'key'
=>
array
(
'x'
=>
1
),
'sparse'
=>
true
,
'unique'
=>
true
)
,
[
'key'
=>
[
'x'
=>
1
],
'sparse'
=>
true
,
'unique'
=>
true
]
,
array
(
'key'
=>
array
(
'y'
=>
-
1
,
'z'
=>
1
))
,
[
'key'
=>
[
'y'
=>
-
1
,
'z'
=>
1
]]
,
array
(
'key'
=>
array
(
'g'
=>
'2dsphere'
,
'z'
=>
1
))
,
[
'key'
=>
[
'g'
=>
'2dsphere'
,
'z'
=>
1
]]
,
array
(
'key'
=>
array
(
't'
=>
1
),
'expireAfterSeconds'
=>
0
,
'name'
=>
'my_ttl'
)
,
[
'key'
=>
[
't'
=>
1
],
'expireAfterSeconds'
=>
0
,
'name'
=>
'my_ttl'
]
,
)
;
]
;
$this
->
assertSame
(
$expectedNames
,
$this
->
collection
->
createIndexes
(
$indexes
));
$this
->
assertSame
(
$expectedNames
,
$this
->
collection
->
createIndexes
(
$indexes
));
...
@@ -90,12 +90,12 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
...
@@ -90,12 +90,12 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testCreateIndexesRequiresAtLeastOneIndex
()
public
function
testCreateIndexesRequiresAtLeastOneIndex
()
{
{
$this
->
assertSame
(
array
(),
$this
->
collection
->
createIndexes
(
array
()
));
$this
->
assertSame
(
[],
$this
->
collection
->
createIndexes
([]
));
}
}
public
function
testDropIndex
()
public
function
testDropIndex
()
{
{
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
array
(
'x'
=>
1
)
));
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
[
'x'
=>
1
]
));
$this
->
assertIndexExists
(
'x_1'
);
$this
->
assertIndexExists
(
'x_1'
);
$this
->
assertCommandSucceeded
(
$this
->
collection
->
dropIndex
(
'x_1'
));
$this
->
assertCommandSucceeded
(
$this
->
collection
->
dropIndex
(
'x_1'
));
...
@@ -111,7 +111,7 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
...
@@ -111,7 +111,7 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testDropIndexShouldNotAllowEmptyIndexName
()
public
function
testDropIndexShouldNotAllowEmptyIndexName
()
{
{
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
array
(
'x'
=>
1
)
));
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
[
'x'
=>
1
]
));
$this
->
assertIndexExists
(
'x_1'
);
$this
->
assertIndexExists
(
'x_1'
);
$this
->
collection
->
dropIndex
(
''
);
$this
->
collection
->
dropIndex
(
''
);
}
}
...
@@ -121,15 +121,15 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
...
@@ -121,15 +121,15 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
*/
*/
public
function
testDropIndexShouldNotAllowWildcardCharacter
()
public
function
testDropIndexShouldNotAllowWildcardCharacter
()
{
{
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
array
(
'x'
=>
1
)
));
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
[
'x'
=>
1
]
));
$this
->
assertIndexExists
(
'x_1'
);
$this
->
assertIndexExists
(
'x_1'
);
$this
->
collection
->
dropIndex
(
'*'
);
$this
->
collection
->
dropIndex
(
'*'
);
}
}
public
function
testDropIndexes
()
public
function
testDropIndexes
()
{
{
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
array
(
'x'
=>
1
)
));
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
[
'x'
=>
1
]
));
$this
->
assertSame
(
'y_1'
,
$this
->
collection
->
createIndex
(
array
(
'y'
=>
1
)
));
$this
->
assertSame
(
'y_1'
,
$this
->
collection
->
createIndex
(
[
'y'
=>
1
]
));
$this
->
assertIndexExists
(
'x_1'
);
$this
->
assertIndexExists
(
'x_1'
);
$this
->
assertIndexExists
(
'y_1'
);
$this
->
assertIndexExists
(
'y_1'
);
$this
->
assertCommandSucceeded
(
$this
->
collection
->
dropIndexes
());
$this
->
assertCommandSucceeded
(
$this
->
collection
->
dropIndexes
());
...
@@ -147,7 +147,7 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
...
@@ -147,7 +147,7 @@ class IndexManagementFunctionalTest extends FunctionalTestCase
public
function
testListIndexes
()
public
function
testListIndexes
()
{
{
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
array
(
'x'
=>
1
)
));
$this
->
assertSame
(
'x_1'
,
$this
->
collection
->
createIndex
(
[
'x'
=>
1
]
));
$indexes
=
$this
->
collection
->
listIndexes
();
$indexes
=
$this
->
collection
->
listIndexes
();
$this
->
assertInstanceOf
(
'MongoDB\Model\IndexInfoIterator'
,
$indexes
);
$this
->
assertInstanceOf
(
'MongoDB\Model\IndexInfoIterator'
,
$indexes
);
...
...
tests/Database/CollectionManagementFunctionalTest.php
View file @
4043b265
...
@@ -23,11 +23,11 @@ class CollectionManagementFunctionalTest extends FunctionalTestCase
...
@@ -23,11 +23,11 @@ class CollectionManagementFunctionalTest extends FunctionalTestCase
});
});
$cappedCollectionName
=
$this
->
getCollectionName
()
.
'.capped'
;
$cappedCollectionName
=
$this
->
getCollectionName
()
.
'.capped'
;
$cappedCollectionOptions
=
array
(
$cappedCollectionOptions
=
[
'capped'
=>
true
,
'capped'
=>
true
,
'max'
=>
100
,
'max'
=>
100
,
'size'
=>
1048576
,
'size'
=>
1048576
,
)
;
]
;
$commandResult
=
$this
->
database
->
createCollection
(
$cappedCollectionName
,
$cappedCollectionOptions
);
$commandResult
=
$this
->
database
->
createCollection
(
$cappedCollectionName
,
$cappedCollectionOptions
);
$this
->
assertCommandSucceeded
(
$commandResult
);
$this
->
assertCommandSucceeded
(
$commandResult
);
...
@@ -70,7 +70,7 @@ class CollectionManagementFunctionalTest extends FunctionalTestCase
...
@@ -70,7 +70,7 @@ class CollectionManagementFunctionalTest extends FunctionalTestCase
$this
->
assertCommandSucceeded
(
$commandResult
);
$this
->
assertCommandSucceeded
(
$commandResult
);
$collectionName
=
$this
->
getCollectionName
();
$collectionName
=
$this
->
getCollectionName
();
$options
=
array
(
'filter'
=>
array
(
'name'
=>
$collectionName
))
;
$options
=
[
'filter'
=>
[
'name'
=>
$collectionName
]]
;
$collections
=
$this
->
database
->
listCollections
(
$options
);
$collections
=
$this
->
database
->
listCollections
(
$options
);
$this
->
assertInstanceOf
(
'MongoDB\Model\CollectionInfoIterator'
,
$collections
);
$this
->
assertInstanceOf
(
'MongoDB\Model\CollectionInfoIterator'
,
$collections
);
...
...
tests/Database/DatabaseFunctionalTest.php
View file @
4043b265
...
@@ -22,10 +22,10 @@ class DatabaseFunctionalTest extends FunctionalTestCase
...
@@ -22,10 +22,10 @@ class DatabaseFunctionalTest extends FunctionalTestCase
public
function
provideInvalidDatabaseValues
()
public
function
provideInvalidDatabaseValues
()
{
{
return
array
(
return
[
array
(
null
)
,
[
null
]
,
array
(
''
)
,
[
''
]
,
)
;
]
;
}
}
public
function
testToString
()
public
function
testToString
()
...
...
tests/FunctionalTestCase.php
View file @
4043b265
...
@@ -22,8 +22,8 @@ abstract class FunctionalTestCase extends TestCase
...
@@ -22,8 +22,8 @@ abstract class FunctionalTestCase extends TestCase
{
{
list
(
$databaseName
,
$collectionName
)
=
explode
(
'.'
,
$namespace
,
2
);
list
(
$databaseName
,
$collectionName
)
=
explode
(
'.'
,
$namespace
,
2
);
$cursor
=
$this
->
manager
->
executeCommand
(
$databaseName
,
new
Command
(
array
(
'count'
=>
$collectionName
)
));
$cursor
=
$this
->
manager
->
executeCommand
(
$databaseName
,
new
Command
(
[
'count'
=>
$collectionName
]
));
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
$document
=
current
(
$cursor
->
toArray
());
$document
=
current
(
$cursor
->
toArray
());
$this
->
assertArrayHasKey
(
'n'
,
$document
);
$this
->
assertArrayHasKey
(
'n'
,
$document
);
...
@@ -77,11 +77,11 @@ abstract class FunctionalTestCase extends TestCase
...
@@ -77,11 +77,11 @@ abstract class FunctionalTestCase extends TestCase
{
{
$cursor
=
$this
->
manager
->
executeCommand
(
$cursor
=
$this
->
manager
->
executeCommand
(
$this
->
getDatabaseName
(),
$this
->
getDatabaseName
(),
new
Command
(
array
(
'buildInfo'
=>
1
)
),
new
Command
(
[
'buildInfo'
=>
1
]
),
$readPreference
?:
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
)
$readPreference
?:
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
)
);
);
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
)
);
$cursor
->
setTypeMap
(
[
'root'
=>
'array'
,
'document'
=>
'array'
]
);
$document
=
current
(
$cursor
->
toArray
());
$document
=
current
(
$cursor
->
toArray
());
return
$document
[
'version'
];
return
$document
[
'version'
];
...
...
tests/Model/CollectionInfoTest.php
View file @
4043b265
...
@@ -9,32 +9,32 @@ class CollectionInfoTest extends TestCase
...
@@ -9,32 +9,32 @@ class CollectionInfoTest extends TestCase
{
{
public
function
testGetName
()
public
function
testGetName
()
{
{
$info
=
new
CollectionInfo
(
array
(
'name'
=>
'foo'
)
);
$info
=
new
CollectionInfo
(
[
'name'
=>
'foo'
]
);
$this
->
assertSame
(
'foo'
,
$info
->
getName
());
$this
->
assertSame
(
'foo'
,
$info
->
getName
());
}
}
public
function
testGetOptions
()
public
function
testGetOptions
()
{
{
$info
=
new
CollectionInfo
(
array
(
'name'
=>
'foo'
)
);
$info
=
new
CollectionInfo
(
[
'name'
=>
'foo'
]
);
$this
->
assertSame
(
array
()
,
$info
->
getOptions
());
$this
->
assertSame
(
[]
,
$info
->
getOptions
());
$info
=
new
CollectionInfo
(
array
(
'name'
=>
'foo'
,
'options'
=>
array
(
'capped'
=>
true
,
'size'
=>
1048576
))
);
$info
=
new
CollectionInfo
(
[
'name'
=>
'foo'
,
'options'
=>
[
'capped'
=>
true
,
'size'
=>
1048576
]]
);
$this
->
assertSame
(
array
(
'capped'
=>
true
,
'size'
=>
1048576
)
,
$info
->
getOptions
());
$this
->
assertSame
(
[
'capped'
=>
true
,
'size'
=>
1048576
]
,
$info
->
getOptions
());
}
}
public
function
testCappedCollectionMethods
()
public
function
testCappedCollectionMethods
()
{
{
$info
=
new
CollectionInfo
(
array
(
'name'
=>
'foo'
)
);
$info
=
new
CollectionInfo
(
[
'name'
=>
'foo'
]
);
$this
->
assertFalse
(
$info
->
isCapped
());
$this
->
assertFalse
(
$info
->
isCapped
());
$this
->
assertNull
(
$info
->
getCappedMax
());
$this
->
assertNull
(
$info
->
getCappedMax
());
$this
->
assertNull
(
$info
->
getCappedSize
());
$this
->
assertNull
(
$info
->
getCappedSize
());
$info
=
new
CollectionInfo
(
array
(
'name'
=>
'foo'
,
'options'
=>
array
(
'capped'
=>
true
,
'size'
=>
1048576
))
);
$info
=
new
CollectionInfo
(
[
'name'
=>
'foo'
,
'options'
=>
[
'capped'
=>
true
,
'size'
=>
1048576
]]
);
$this
->
assertTrue
(
$info
->
isCapped
());
$this
->
assertTrue
(
$info
->
isCapped
());
$this
->
assertNull
(
$info
->
getCappedMax
());
$this
->
assertNull
(
$info
->
getCappedMax
());
$this
->
assertSame
(
1048576
,
$info
->
getCappedSize
());
$this
->
assertSame
(
1048576
,
$info
->
getCappedSize
());
$info
=
new
CollectionInfo
(
array
(
'name'
=>
'foo'
,
'options'
=>
array
(
'capped'
=>
true
,
'size'
=>
1048576
,
'max'
=>
100
))
);
$info
=
new
CollectionInfo
(
[
'name'
=>
'foo'
,
'options'
=>
[
'capped'
=>
true
,
'size'
=>
1048576
,
'max'
=>
100
]]
);
$this
->
assertTrue
(
$info
->
isCapped
());
$this
->
assertTrue
(
$info
->
isCapped
());
$this
->
assertSame
(
100
,
$info
->
getCappedMax
());
$this
->
assertSame
(
100
,
$info
->
getCappedMax
());
$this
->
assertSame
(
1048576
,
$info
->
getCappedSize
());
$this
->
assertSame
(
1048576
,
$info
->
getCappedSize
());
...
@@ -42,10 +42,10 @@ class CollectionInfoTest extends TestCase
...
@@ -42,10 +42,10 @@ class CollectionInfoTest extends TestCase
public
function
testDebugInfo
()
public
function
testDebugInfo
()
{
{
$expectedInfo
=
array
(
$expectedInfo
=
[
'name'
=>
'foo'
,
'name'
=>
'foo'
,
'options'
=>
array
(
'capped'
=>
true
,
'size'
=>
1048576
)
,
'options'
=>
[
'capped'
=>
true
,
'size'
=>
1048576
]
,
)
;
]
;
$info
=
new
CollectionInfo
(
$expectedInfo
);
$info
=
new
CollectionInfo
(
$expectedInfo
);
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
...
...
tests/Model/DatabaseInfoTest.php
View file @
4043b265
...
@@ -9,32 +9,32 @@ class DatabaseInfoTest extends TestCase
...
@@ -9,32 +9,32 @@ class DatabaseInfoTest extends TestCase
{
{
public
function
testGetName
()
public
function
testGetName
()
{
{
$info
=
new
DatabaseInfo
(
array
(
'name'
=>
'foo'
)
);
$info
=
new
DatabaseInfo
(
[
'name'
=>
'foo'
]
);
$this
->
assertSame
(
'foo'
,
$info
->
getName
());
$this
->
assertSame
(
'foo'
,
$info
->
getName
());
}
}
public
function
testGetSizeOnDisk
()
public
function
testGetSizeOnDisk
()
{
{
$info
=
new
DatabaseInfo
(
array
(
'sizeOnDisk'
=>
1048576
)
);
$info
=
new
DatabaseInfo
(
[
'sizeOnDisk'
=>
1048576
]
);
$this
->
assertSame
(
1048576
,
$info
->
getSizeOnDisk
());
$this
->
assertSame
(
1048576
,
$info
->
getSizeOnDisk
());
}
}
public
function
testIsEmpty
()
public
function
testIsEmpty
()
{
{
$info
=
new
DatabaseInfo
(
array
(
'empty'
=>
false
)
);
$info
=
new
DatabaseInfo
(
[
'empty'
=>
false
]
);
$this
->
assertFalse
(
$info
->
isEmpty
());
$this
->
assertFalse
(
$info
->
isEmpty
());
$info
=
new
DatabaseInfo
(
array
(
'empty'
=>
true
)
);
$info
=
new
DatabaseInfo
(
[
'empty'
=>
true
]
);
$this
->
assertTrue
(
$info
->
isEmpty
());
$this
->
assertTrue
(
$info
->
isEmpty
());
}
}
public
function
testDebugInfo
()
public
function
testDebugInfo
()
{
{
$expectedInfo
=
array
(
$expectedInfo
=
[
'name'
=>
'foo'
,
'name'
=>
'foo'
,
'sizeOnDisk'
=>
1048576
,
'sizeOnDisk'
=>
1048576
,
'empty'
=>
false
,
'empty'
=>
false
,
)
;
]
;
$info
=
new
DatabaseInfo
(
$expectedInfo
);
$info
=
new
DatabaseInfo
(
$expectedInfo
);
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
...
...
tests/Model/IndexInfoTest.php
View file @
4043b265
...
@@ -9,15 +9,15 @@ class IndexInfoTest extends TestCase
...
@@ -9,15 +9,15 @@ class IndexInfoTest extends TestCase
{
{
public
function
testBasicIndex
()
public
function
testBasicIndex
()
{
{
$info
=
new
IndexInfo
(
array
(
$info
=
new
IndexInfo
(
[
'v'
=>
1
,
'v'
=>
1
,
'key'
=>
array
(
'x'
=>
1
)
,
'key'
=>
[
'x'
=>
1
]
,
'name'
=>
'x_1'
,
'name'
=>
'x_1'
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
)
);
]
);
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
array
(
'x'
=>
1
)
,
$info
->
getKey
());
$this
->
assertSame
(
[
'x'
=>
1
]
,
$info
->
getKey
());
$this
->
assertSame
(
'x_1'
,
$info
->
getName
());
$this
->
assertSame
(
'x_1'
,
$info
->
getName
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertFalse
(
$info
->
isSparse
());
$this
->
assertFalse
(
$info
->
isSparse
());
...
@@ -27,16 +27,16 @@ class IndexInfoTest extends TestCase
...
@@ -27,16 +27,16 @@ class IndexInfoTest extends TestCase
public
function
testSparseIndex
()
public
function
testSparseIndex
()
{
{
$info
=
new
IndexInfo
(
array
(
$info
=
new
IndexInfo
(
[
'v'
=>
1
,
'v'
=>
1
,
'key'
=>
array
(
'y'
=>
1
)
,
'key'
=>
[
'y'
=>
1
]
,
'name'
=>
'y_sparse'
,
'name'
=>
'y_sparse'
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
'sparse'
=>
true
,
'sparse'
=>
true
,
)
);
]
);
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
array
(
'y'
=>
1
)
,
$info
->
getKey
());
$this
->
assertSame
(
[
'y'
=>
1
]
,
$info
->
getKey
());
$this
->
assertSame
(
'y_sparse'
,
$info
->
getName
());
$this
->
assertSame
(
'y_sparse'
,
$info
->
getName
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertTrue
(
$info
->
isSparse
());
$this
->
assertTrue
(
$info
->
isSparse
());
...
@@ -46,16 +46,16 @@ class IndexInfoTest extends TestCase
...
@@ -46,16 +46,16 @@ class IndexInfoTest extends TestCase
public
function
testUniqueIndex
()
public
function
testUniqueIndex
()
{
{
$info
=
new
IndexInfo
(
array
(
$info
=
new
IndexInfo
(
[
'v'
=>
1
,
'v'
=>
1
,
'key'
=>
array
(
'z'
=>
1
)
,
'key'
=>
[
'z'
=>
1
]
,
'name'
=>
'z_unique'
,
'name'
=>
'z_unique'
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
'unique'
=>
true
,
'unique'
=>
true
,
)
);
]
);
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
array
(
'z'
=>
1
)
,
$info
->
getKey
());
$this
->
assertSame
(
[
'z'
=>
1
]
,
$info
->
getKey
());
$this
->
assertSame
(
'z_unique'
,
$info
->
getName
());
$this
->
assertSame
(
'z_unique'
,
$info
->
getName
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertFalse
(
$info
->
isSparse
());
$this
->
assertFalse
(
$info
->
isSparse
());
...
@@ -65,16 +65,16 @@ class IndexInfoTest extends TestCase
...
@@ -65,16 +65,16 @@ class IndexInfoTest extends TestCase
public
function
testTtlIndex
()
public
function
testTtlIndex
()
{
{
$info
=
new
IndexInfo
(
array
(
$info
=
new
IndexInfo
(
[
'v'
=>
1
,
'v'
=>
1
,
'key'
=>
array
(
'z'
=>
1
)
,
'key'
=>
[
'z'
=>
1
]
,
'name'
=>
'z_unique'
,
'name'
=>
'z_unique'
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
'expireAfterSeconds'
=>
100
,
'expireAfterSeconds'
=>
100
,
)
);
]
);
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
1
,
$info
->
getVersion
());
$this
->
assertSame
(
array
(
'z'
=>
1
)
,
$info
->
getKey
());
$this
->
assertSame
(
[
'z'
=>
1
]
,
$info
->
getKey
());
$this
->
assertSame
(
'z_unique'
,
$info
->
getName
());
$this
->
assertSame
(
'z_unique'
,
$info
->
getName
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertSame
(
'foo.bar'
,
$info
->
getNamespace
());
$this
->
assertFalse
(
$info
->
isSparse
());
$this
->
assertFalse
(
$info
->
isSparse
());
...
@@ -86,12 +86,12 @@ class IndexInfoTest extends TestCase
...
@@ -86,12 +86,12 @@ class IndexInfoTest extends TestCase
public
function
testDebugInfo
()
public
function
testDebugInfo
()
{
{
$expectedInfo
=
array
(
$expectedInfo
=
[
'v'
=>
1
,
'v'
=>
1
,
'key'
=>
array
(
'x'
=>
1
)
,
'key'
=>
[
'x'
=>
1
]
,
'name'
=>
'x_1'
,
'name'
=>
'x_1'
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
)
;
]
;
$info
=
new
IndexInfo
(
$expectedInfo
);
$info
=
new
IndexInfo
(
$expectedInfo
);
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
$this
->
assertSame
(
$expectedInfo
,
$info
->
__debugInfo
());
...
...
tests/Model/IndexInputTest.php
View file @
4043b265
...
@@ -12,7 +12,7 @@ class IndexInputTest extends TestCase
...
@@ -12,7 +12,7 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testConstructorShouldRequireKey
()
public
function
testConstructorShouldRequireKey
()
{
{
new
IndexInput
(
array
()
);
new
IndexInput
(
[]
);
}
}
/**
/**
...
@@ -20,7 +20,7 @@ class IndexInputTest extends TestCase
...
@@ -20,7 +20,7 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testConstructorShouldRequireKeyToBeArrayOrObject
()
public
function
testConstructorShouldRequireKeyToBeArrayOrObject
()
{
{
new
IndexInput
(
array
(
'key'
=>
'foo'
)
);
new
IndexInput
(
[
'key'
=>
'foo'
]
);
}
}
/**
/**
...
@@ -28,7 +28,7 @@ class IndexInputTest extends TestCase
...
@@ -28,7 +28,7 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testConstructorShouldRequireKeyOrderToBeScalar
()
public
function
testConstructorShouldRequireKeyOrderToBeScalar
()
{
{
new
IndexInput
(
array
(
'key'
=>
array
(
'x'
=>
array
()))
);
new
IndexInput
(
[
'key'
=>
[
'x'
=>
[]]]
);
}
}
/**
/**
...
@@ -36,7 +36,7 @@ class IndexInputTest extends TestCase
...
@@ -36,7 +36,7 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testConstructorShouldRequireNamespace
()
public
function
testConstructorShouldRequireNamespace
()
{
{
new
IndexInput
(
array
(
'key'
=>
array
(
'x'
=>
1
))
);
new
IndexInput
(
[
'key'
=>
[
'x'
=>
1
]]
);
}
}
/**
/**
...
@@ -44,7 +44,7 @@ class IndexInputTest extends TestCase
...
@@ -44,7 +44,7 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testConstructorShouldRequireNamespaceToBeString
()
public
function
testConstructorShouldRequireNamespaceToBeString
()
{
{
new
IndexInput
(
array
(
'key'
=>
array
(
'x'
=>
1
),
'ns'
=>
1
)
);
new
IndexInput
(
[
'key'
=>
[
'x'
=>
1
],
'ns'
=>
1
]
);
}
}
/**
/**
...
@@ -52,7 +52,7 @@ class IndexInputTest extends TestCase
...
@@ -52,7 +52,7 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testConstructorShouldRequireNameToBeString
()
public
function
testConstructorShouldRequireNameToBeString
()
{
{
new
IndexInput
(
array
(
'key'
=>
array
(
'x'
=>
1
),
'ns'
=>
'foo.bar'
,
'name'
=>
1
)
);
new
IndexInput
(
[
'key'
=>
[
'x'
=>
1
],
'ns'
=>
'foo.bar'
,
'name'
=>
1
]
);
}
}
/**
/**
...
@@ -60,32 +60,32 @@ class IndexInputTest extends TestCase
...
@@ -60,32 +60,32 @@ class IndexInputTest extends TestCase
*/
*/
public
function
testNameGeneration
(
$expectedName
,
array
$key
)
public
function
testNameGeneration
(
$expectedName
,
array
$key
)
{
{
$this
->
assertSame
(
$expectedName
,
(
string
)
new
IndexInput
(
array
(
'key'
=>
$key
,
'ns'
=>
'foo.bar'
)
));
$this
->
assertSame
(
$expectedName
,
(
string
)
new
IndexInput
(
[
'key'
=>
$key
,
'ns'
=>
'foo.bar'
]
));
}
}
public
function
provideExpectedNameAndKey
()
public
function
provideExpectedNameAndKey
()
{
{
return
array
(
return
[
array
(
'x_1'
,
array
(
'x'
=>
1
))
,
[
'x_1'
,
[
'x'
=>
1
]]
,
array
(
'x_1_y_-1'
,
array
(
'x'
=>
1
,
'y'
=>
-
1
))
,
[
'x_1_y_-1'
,
[
'x'
=>
1
,
'y'
=>
-
1
]]
,
array
(
'loc_2dsphere'
,
array
(
'loc'
=>
'2dsphere'
))
,
[
'loc_2dsphere'
,
[
'loc'
=>
'2dsphere'
]]
,
array
(
'loc_2dsphere_x_1'
,
array
(
'loc'
=>
'2dsphere'
,
'x'
=>
1
))
,
[
'loc_2dsphere_x_1'
,
[
'loc'
=>
'2dsphere'
,
'x'
=>
1
]]
,
array
(
'doc_text'
,
array
(
'doc'
=>
'text'
))
,
[
'doc_text'
,
[
'doc'
=>
'text'
]]
,
)
;
]
;
}
}
public
function
testBsonSerialization
()
public
function
testBsonSerialization
()
{
{
$expected
=
array
(
$expected
=
[
'key'
=>
array
(
'x'
=>
1
)
,
'key'
=>
[
'x'
=>
1
]
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
'name'
=>
'x_1'
,
'name'
=>
'x_1'
,
)
;
]
;
$indexInput
=
new
IndexInput
(
array
(
$indexInput
=
new
IndexInput
(
[
'key'
=>
array
(
'x'
=>
1
)
,
'key'
=>
[
'x'
=>
1
]
,
'ns'
=>
'foo.bar'
,
'ns'
=>
'foo.bar'
,
)
);
]
);
$this
->
assertInstanceOf
(
'MongoDB\BSON\Serializable'
,
$indexInput
);
$this
->
assertInstanceOf
(
'MongoDB\BSON\Serializable'
,
$indexInput
);
$this
->
assertEquals
(
$expected
,
$indexInput
->
bsonSerialize
());
$this
->
assertEquals
(
$expected
,
$indexInput
->
bsonSerialize
());
...
...
tests/Operation/AggregateTest.php
View file @
4043b265
...
@@ -12,7 +12,7 @@ class AggregateTest extends TestCase
...
@@ -12,7 +12,7 @@ class AggregateTest extends TestCase
*/
*/
public
function
testConstructorPipelineArgumentMustNotBeEmpty
()
public
function
testConstructorPipelineArgumentMustNotBeEmpty
()
{
{
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
()
);
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]
);
}
}
/**
/**
...
@@ -21,7 +21,7 @@ class AggregateTest extends TestCase
...
@@ -21,7 +21,7 @@ class AggregateTest extends TestCase
*/
*/
public
function
testConstructorPipelineArgumentMustBeAList
()
public
function
testConstructorPipelineArgumentMustBeAList
()
{
{
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
1
=>
array
(
'$match'
=>
array
(
'x'
=>
1
)))
);
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
1
=>
[
'$match'
=>
[
'x'
=>
1
]]]
);
}
}
/**
/**
...
@@ -30,31 +30,31 @@ class AggregateTest extends TestCase
...
@@ -30,31 +30,31 @@ class AggregateTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
array
(
'$match'
=>
array
(
'x'
=>
1
)))
,
$options
);
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[[
'$match'
=>
[
'x'
=>
1
]]]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'allowDiskUse'
=>
$value
)
;
$options
[][]
=
[
'allowDiskUse'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'batchSize'
=>
$value
)
;
$options
[][]
=
[
'batchSize'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'maxTimeMS'
=>
$value
)
;
$options
[][]
=
[
'maxTimeMS'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
$options
[][]
=
array
(
'readPreference'
=>
$value
)
;
$options
[][]
=
[
'readPreference'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'useCursor'
=>
$value
)
;
$options
[][]
=
[
'useCursor'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
@@ -69,8 +69,8 @@ class AggregateTest extends TestCase
...
@@ -69,8 +69,8 @@ class AggregateTest extends TestCase
new
Aggregate
(
new
Aggregate
(
$this
->
getDatabaseName
(),
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$this
->
getCollectionName
(),
array
(
array
(
'$match'
=>
array
(
'x'
=>
1
)))
,
[[
'$match'
=>
[
'x'
=>
1
]]]
,
array
(
'batchSize'
=>
100
,
'useCursor'
=>
false
)
[
'batchSize'
=>
100
,
'useCursor'
=>
false
]
);
);
}
}
}
}
tests/Operation/BulkWriteTest.php
View file @
4043b265
This diff is collapsed.
Click to expand it.
tests/Operation/CountTest.php
View file @
4043b265
...
@@ -21,31 +21,31 @@ class CountTest extends TestCase
...
@@ -21,31 +21,31 @@ class CountTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
Count
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
()
,
$options
);
new
Count
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidHintValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidHintValues
()
as
$value
)
{
$options
[][]
=
array
(
'hint'
=>
$value
)
;
$options
[][]
=
[
'hint'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'limit'
=>
$value
)
;
$options
[][]
=
[
'limit'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'maxTimeMS'
=>
$value
)
;
$options
[][]
=
[
'maxTimeMS'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
$options
[][]
=
array
(
'readPreference'
=>
$value
)
;
$options
[][]
=
[
'readPreference'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'skip'
=>
$value
)
;
$options
[][]
=
[
'skip'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
@@ -53,6 +53,6 @@ class CountTest extends TestCase
...
@@ -53,6 +53,6 @@ class CountTest extends TestCase
private
function
getInvalidHintValues
()
private
function
getInvalidHintValues
()
{
{
return
array
(
123
,
3.14
,
true
)
;
return
[
123
,
3.14
,
true
]
;
}
}
}
}
tests/Operation/DeleteTest.php
View file @
4043b265
...
@@ -22,12 +22,12 @@ class DeleteTest extends TestCase
...
@@ -22,12 +22,12 @@ class DeleteTest extends TestCase
*/
*/
public
function
testConstructorLimitArgumentMustBeOneOrZero
(
$limit
)
public
function
testConstructorLimitArgumentMustBeOneOrZero
(
$limit
)
{
{
new
Delete
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
()
,
$limit
);
new
Delete
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]
,
$limit
);
}
}
public
function
provideInvalidLimitValues
()
public
function
provideInvalidLimitValues
()
{
{
return
$this
->
wrapValuesForDataProvider
(
array_merge
(
$this
->
getInvalidIntegerValues
(),
array
(
-
1
,
2
)
));
return
$this
->
wrapValuesForDataProvider
(
array_merge
(
$this
->
getInvalidIntegerValues
(),
[
-
1
,
2
]
));
}
}
/**
/**
...
@@ -36,15 +36,15 @@ class DeleteTest extends TestCase
...
@@ -36,15 +36,15 @@ class DeleteTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
Delete
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
()
,
1
,
$options
);
new
Delete
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]
,
1
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
array
(
'writeConcern'
=>
$value
)
;
$options
[][]
=
[
'writeConcern'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
...
tests/Operation/DistinctTest.php
View file @
4043b265
...
@@ -21,19 +21,19 @@ class DistinctTest extends TestCase
...
@@ -21,19 +21,19 @@ class DistinctTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
Distinct
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
'x'
,
array
()
,
$options
);
new
Distinct
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
'x'
,
[]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'maxTimeMS'
=>
$value
)
;
$options
[][]
=
[
'maxTimeMS'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
$options
[][]
=
array
(
'readPreference'
=>
$value
)
;
$options
[][]
=
[
'readPreference'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
...
tests/Operation/FindTest.php
View file @
4043b265
...
@@ -21,59 +21,59 @@ class FindTest extends TestCase
...
@@ -21,59 +21,59 @@ class FindTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
Find
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
()
,
$options
);
new
Find
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'allowPartialResults'
=>
$value
)
;
$options
[][]
=
[
'allowPartialResults'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'batchSize'
=>
$value
)
;
$options
[][]
=
[
'batchSize'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidStringValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidStringValues
()
as
$value
)
{
$options
[][]
=
array
(
'comment'
=>
$value
)
;
$options
[][]
=
[
'comment'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'cursorType'
=>
$value
)
;
$options
[][]
=
[
'cursorType'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'limit'
=>
$value
)
;
$options
[][]
=
[
'limit'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'maxTimeMS'
=>
$value
)
;
$options
[][]
=
[
'maxTimeMS'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
$options
[][]
=
array
(
'modifiers'
=>
$value
)
;
$options
[][]
=
[
'modifiers'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'oplogReplay'
=>
$value
)
;
$options
[][]
=
[
'oplogReplay'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
$options
[][]
=
array
(
'projection'
=>
$value
)
;
$options
[][]
=
[
'projection'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidReadPreferenceValues
()
as
$value
)
{
$options
[][]
=
array
(
'readPreference'
=>
$value
)
;
$options
[][]
=
[
'readPreference'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
array
(
'skip'
=>
$value
)
;
$options
[][]
=
[
'skip'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidDocumentValues
()
as
$value
)
{
$options
[][]
=
array
(
'sort'
=>
$value
)
;
$options
[][]
=
[
'sort'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
@@ -85,11 +85,11 @@ class FindTest extends TestCase
...
@@ -85,11 +85,11 @@ class FindTest extends TestCase
*/
*/
public
function
testConstructorCursorTypeOption
(
$cursorType
)
public
function
testConstructorCursorTypeOption
(
$cursorType
)
{
{
new
Find
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(),
array
(
'cursorType'
=>
$cursorType
)
);
new
Find
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[],
[
'cursorType'
=>
$cursorType
]
);
}
}
public
function
provideInvalidConstructorCursorTypeOptions
()
public
function
provideInvalidConstructorCursorTypeOptions
()
{
{
return
$this
->
wrapValuesForDataProvider
(
array
(
-
1
,
0
,
4
)
);
return
$this
->
wrapValuesForDataProvider
(
[
-
1
,
0
,
4
]
);
}
}
}
}
tests/Operation/InsertManyTest.php
View file @
4043b265
...
@@ -12,7 +12,7 @@ class InsertManyTest extends TestCase
...
@@ -12,7 +12,7 @@ class InsertManyTest extends TestCase
*/
*/
public
function
testConstructorDocumentsMustNotBeEmpty
()
public
function
testConstructorDocumentsMustNotBeEmpty
()
{
{
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
()
);
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[]
);
}
}
/**
/**
...
@@ -21,7 +21,7 @@ class InsertManyTest extends TestCase
...
@@ -21,7 +21,7 @@ class InsertManyTest extends TestCase
*/
*/
public
function
testConstructorDocumentsMustBeAList
()
public
function
testConstructorDocumentsMustBeAList
()
{
{
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
1
=>
array
(
'x'
=>
1
))
);
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
1
=>
[
'x'
=>
1
]]
);
}
}
/**
/**
...
@@ -31,7 +31,7 @@ class InsertManyTest extends TestCase
...
@@ -31,7 +31,7 @@ class InsertManyTest extends TestCase
*/
*/
public
function
testConstructorDocumentsArgumentElementTypeChecks
(
$document
)
public
function
testConstructorDocumentsArgumentElementTypeChecks
(
$document
)
{
{
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
$document
)
);
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
$document
]
);
}
}
/**
/**
...
@@ -40,19 +40,19 @@ class InsertManyTest extends TestCase
...
@@ -40,19 +40,19 @@ class InsertManyTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
array
(
'x'
=>
1
))
,
$options
);
new
InsertMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[[
'x'
=>
1
]]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'ordered'
=>
$value
)
;
$options
[][]
=
[
'ordered'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
array
(
'writeConcern'
=>
$value
)
;
$options
[][]
=
[
'writeConcern'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
...
tests/Operation/InsertOneTest.php
View file @
4043b265
...
@@ -21,15 +21,15 @@ class InsertOneTest extends TestCase
...
@@ -21,15 +21,15 @@ class InsertOneTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
InsertOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
)
,
$options
);
new
InsertOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
array
(
'writeConcern'
=>
$value
)
;
$options
[][]
=
[
'writeConcern'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
...
tests/Operation/ReplaceOneTest.php
View file @
4043b265
...
@@ -12,7 +12,7 @@ class ReplaceOneTest extends TestCase
...
@@ -12,7 +12,7 @@ class ReplaceOneTest extends TestCase
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
{
{
new
ReplaceOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
array
(
'y'
=>
1
)
);
new
ReplaceOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
[
'y'
=>
1
]
);
}
}
/**
/**
...
@@ -21,7 +21,7 @@ class ReplaceOneTest extends TestCase
...
@@ -21,7 +21,7 @@ class ReplaceOneTest extends TestCase
*/
*/
public
function
testConstructorReplacementArgumentTypeCheck
(
$replacement
)
public
function
testConstructorReplacementArgumentTypeCheck
(
$replacement
)
{
{
new
ReplaceOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
)
,
$replacement
);
new
ReplaceOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
]
,
$replacement
);
}
}
/**
/**
...
@@ -30,6 +30,6 @@ class ReplaceOneTest extends TestCase
...
@@ -30,6 +30,6 @@ class ReplaceOneTest extends TestCase
*/
*/
public
function
testConstructorReplacementArgumentRequiresNoOperators
()
public
function
testConstructorReplacementArgumentRequiresNoOperators
()
{
{
new
ReplaceOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
),
array
(
'$set'
=>
array
(
'x'
=>
1
))
);
new
ReplaceOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
],
[
'$set'
=>
[
'x'
=>
1
]]
);
}
}
}
}
tests/Operation/TestCase.php
View file @
4043b265
...
@@ -22,41 +22,41 @@ abstract class TestCase extends BaseTestCase
...
@@ -22,41 +22,41 @@ abstract class TestCase extends BaseTestCase
protected
function
getInvalidArrayValues
()
protected
function
getInvalidArrayValues
()
{
{
return
array
(
123
,
3.14
,
'foo'
,
true
,
new
stdClass
)
;
return
[
123
,
3.14
,
'foo'
,
true
,
new
stdClass
]
;
}
}
protected
function
getInvalidBooleanValues
()
protected
function
getInvalidBooleanValues
()
{
{
return
array
(
123
,
3.14
,
'foo'
,
array
(),
new
stdClass
)
;
return
[
123
,
3.14
,
'foo'
,
[],
new
stdClass
]
;
}
}
protected
function
getInvalidDocumentValues
()
protected
function
getInvalidDocumentValues
()
{
{
return
array
(
123
,
3.14
,
'foo'
,
true
)
;
return
[
123
,
3.14
,
'foo'
,
true
]
;
}
}
protected
function
getInvalidIntegerValues
()
protected
function
getInvalidIntegerValues
()
{
{
return
array
(
3.14
,
'foo'
,
true
,
array
(),
new
stdClass
)
;
return
[
3.14
,
'foo'
,
true
,
[],
new
stdClass
]
;
}
}
protected
function
getInvalidStringValues
()
protected
function
getInvalidStringValues
()
{
{
return
array
(
123
,
3.14
,
true
,
array
(),
new
stdClass
)
;
return
[
123
,
3.14
,
true
,
[],
new
stdClass
]
;
}
}
protected
function
getInvalidReadPreferenceValues
()
protected
function
getInvalidReadPreferenceValues
()
{
{
return
array
(
123
,
3.14
,
'foo'
,
true
,
array
(),
new
stdClass
)
;
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
]
;
}
}
protected
function
getInvalidWriteConcernValues
()
protected
function
getInvalidWriteConcernValues
()
{
{
return
array
(
123
,
3.14
,
'foo'
,
true
,
array
(),
new
stdClass
)
;
return
[
123
,
3.14
,
'foo'
,
true
,
[],
new
stdClass
]
;
}
}
protected
function
wrapValuesForDataProvider
(
array
$values
)
protected
function
wrapValuesForDataProvider
(
array
$values
)
{
{
return
array_map
(
function
(
$value
)
{
return
array
(
$value
)
;
},
$values
);
return
array_map
(
function
(
$value
)
{
return
[
$value
]
;
},
$values
);
}
}
}
}
tests/Operation/UpdateManyTest.php
View file @
4043b265
...
@@ -12,7 +12,7 @@ class UpdateManyTest extends TestCase
...
@@ -12,7 +12,7 @@ class UpdateManyTest extends TestCase
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
{
{
new
UpdateMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
array
(
'$set'
=>
array
(
'x'
=>
1
))
);
new
UpdateMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
[
'$set'
=>
[
'x'
=>
1
]]
);
}
}
/**
/**
...
@@ -21,7 +21,7 @@ class UpdateManyTest extends TestCase
...
@@ -21,7 +21,7 @@ class UpdateManyTest extends TestCase
*/
*/
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
{
{
new
UpdateMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
)
,
$update
);
new
UpdateMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
]
,
$update
);
}
}
/**
/**
...
@@ -30,6 +30,6 @@ class UpdateManyTest extends TestCase
...
@@ -30,6 +30,6 @@ class UpdateManyTest extends TestCase
*/
*/
public
function
testConstructorUpdateArgumentRequiresOperators
()
public
function
testConstructorUpdateArgumentRequiresOperators
()
{
{
new
UpdateMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
),
array
(
'y'
=>
1
)
);
new
UpdateMany
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
],
[
'y'
=>
1
]
);
}
}
}
}
tests/Operation/UpdateOneTest.php
View file @
4043b265
...
@@ -12,7 +12,7 @@ class UpdateOneTest extends TestCase
...
@@ -12,7 +12,7 @@ class UpdateOneTest extends TestCase
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
{
{
new
UpdateOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
array
(
'$set'
=>
array
(
'x'
=>
1
))
);
new
UpdateOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
[
'$set'
=>
[
'x'
=>
1
]]
);
}
}
/**
/**
...
@@ -21,7 +21,7 @@ class UpdateOneTest extends TestCase
...
@@ -21,7 +21,7 @@ class UpdateOneTest extends TestCase
*/
*/
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
{
{
new
UpdateOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
)
,
$update
);
new
UpdateOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
]
,
$update
);
}
}
/**
/**
...
@@ -30,6 +30,6 @@ class UpdateOneTest extends TestCase
...
@@ -30,6 +30,6 @@ class UpdateOneTest extends TestCase
*/
*/
public
function
testConstructorUpdateArgumentRequiresOperators
()
public
function
testConstructorUpdateArgumentRequiresOperators
()
{
{
new
UpdateOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
),
array
(
'y'
=>
1
)
);
new
UpdateOne
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
],
[
'y'
=>
1
]
);
}
}
}
}
tests/Operation/UpdateTest.php
View file @
4043b265
...
@@ -13,7 +13,7 @@ class UpdateTest extends TestCase
...
@@ -13,7 +13,7 @@ class UpdateTest extends TestCase
*/
*/
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
public
function
testConstructorFilterArgumentTypeCheck
(
$filter
)
{
{
new
Update
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
array
(
'$set'
=>
array
(
'x'
=>
1
))
);
new
Update
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$filter
,
[
'$set'
=>
[
'x'
=>
1
]]
);
}
}
/**
/**
...
@@ -23,7 +23,7 @@ class UpdateTest extends TestCase
...
@@ -23,7 +23,7 @@ class UpdateTest extends TestCase
*/
*/
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
public
function
testConstructorUpdateArgumentTypeCheck
(
$update
)
{
{
new
Update
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
)
,
$update
);
new
Update
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
]
,
$update
);
}
}
/**
/**
...
@@ -32,23 +32,23 @@ class UpdateTest extends TestCase
...
@@ -32,23 +32,23 @@ class UpdateTest extends TestCase
*/
*/
public
function
testConstructorOptionTypeChecks
(
array
$options
)
public
function
testConstructorOptionTypeChecks
(
array
$options
)
{
{
new
Update
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
array
(
'x'
=>
1
),
array
(
'y'
=>
1
)
,
$options
);
new
Update
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'x'
=>
1
],
[
'y'
=>
1
]
,
$options
);
}
}
public
function
provideInvalidConstructorOptions
()
public
function
provideInvalidConstructorOptions
()
{
{
$options
=
array
()
;
$options
=
[]
;
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'multi'
=>
$value
)
;
$options
[][]
=
[
'multi'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidBooleanValues
()
as
$value
)
{
$options
[][]
=
array
(
'upsert'
=>
$value
)
;
$options
[][]
=
[
'upsert'
=>
$value
]
;
}
}
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
foreach
(
$this
->
getInvalidWriteConcernValues
()
as
$value
)
{
$options
[][]
=
array
(
'writeConcern'
=>
$value
)
;
$options
[][]
=
[
'writeConcern'
=>
$value
]
;
}
}
return
$options
;
return
$options
;
...
...
tests/PedantryTest.php
View file @
4043b265
...
@@ -56,7 +56,7 @@ class PedantryTest extends \PHPUnit_Framework_TestCase
...
@@ -56,7 +56,7 @@ class PedantryTest extends \PHPUnit_Framework_TestCase
public
function
provideProjectClassNames
()
public
function
provideProjectClassNames
()
{
{
$classNames
=
array
()
;
$classNames
=
[]
;
$srcDir
=
realpath
(
__DIR__
.
'/../src/'
);
$srcDir
=
realpath
(
__DIR__
.
'/../src/'
);
$files
=
new
RegexIterator
(
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$srcDir
)),
'/\.php$/i'
);
$files
=
new
RegexIterator
(
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$srcDir
)),
'/\.php$/i'
);
...
...
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