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
0c09ed1f
Commit
0c09ed1f
authored
Apr 19, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v1.3'
parents
1a89e8b2
b9f35916
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
FindAndModify.php
src/Operation/FindAndModify.php
+2
-2
FindAndModifyFunctionalTest.php
tests/Operation/FindAndModifyFunctionalTest.php
+26
-0
No files found.
src/Operation/FindAndModify.php
View file @
0c09ed1f
...
...
@@ -210,7 +210,7 @@ class FindAndModify implements Executable, Explainable
throw
UnsupportedException
::
writeConcernNotSupported
();
}
$cursor
=
$server
->
execute
Read
WriteCommand
(
$this
->
databaseName
,
new
Command
(
$this
->
createCommandDocument
(
$server
)),
$this
->
createOptions
());
$cursor
=
$server
->
executeWriteCommand
(
$this
->
databaseName
,
new
Command
(
$this
->
createCommandDocument
(
$server
)),
$this
->
createOptions
());
$result
=
current
(
$cursor
->
toArray
());
if
(
!
isset
(
$result
->
value
))
{
...
...
@@ -284,7 +284,7 @@ class FindAndModify implements Executable, Explainable
/**
* Create options for executing the command.
*
* @see http://php.net/manual/en/mongodb-driver-server.execute
read
writecommand.php
* @see http://php.net/manual/en/mongodb-driver-server.executewritecommand.php
* @return array
*/
private
function
createOptions
()
...
...
tests/Operation/FindAndModifyFunctionalTest.php
View file @
0c09ed1f
...
...
@@ -3,6 +3,8 @@
namespace
MongoDB\Tests\Operation
;
use
MongoDB\Driver\BulkWrite
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Model\BSONDocument
;
use
MongoDB\Operation\FindAndModify
;
use
MongoDB\Tests\CommandObserver
;
...
...
@@ -10,6 +12,30 @@ use stdClass;
class
FindAndModifyFunctionalTest
extends
FunctionalTestCase
{
/**
* @see https://jira.mongodb.org/browse/PHPLIB-344
*/
public
function
testManagerReadConcernIsOmitted
()
{
$manager
=
new
Manager
(
$this
->
getUri
(),
[
'readConcernLevel'
=>
'majority'
]);
$server
=
$manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
(
new
CommandObserver
)
->
observe
(
function
()
use
(
$server
)
{
$operation
=
new
FindAndModify
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
[
'remove'
=>
true
]
);
$operation
->
execute
(
$server
);
},
function
(
stdClass
$command
)
{
$this
->
assertObjectNotHasAttribute
(
'readConcern'
,
$command
);
}
);
}
public
function
testDefaultWriteConcernIsOmitted
()
{
(
new
CommandObserver
)
->
observe
(
...
...
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