Commit b9f35916 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #530

parents 5d2a8a46 0395858d
...@@ -210,7 +210,7 @@ class FindAndModify implements Executable ...@@ -210,7 +210,7 @@ class FindAndModify implements Executable
throw UnsupportedException::writeConcernNotSupported(); throw UnsupportedException::writeConcernNotSupported();
} }
$cursor = $server->executeReadWriteCommand($this->databaseName, $this->createCommand($server), $this->createOptions()); $cursor = $server->executeWriteCommand($this->databaseName, $this->createCommand($server), $this->createOptions());
$result = current($cursor->toArray()); $result = current($cursor->toArray());
if ( ! isset($result->value)) { if ( ! isset($result->value)) {
...@@ -280,7 +280,7 @@ class FindAndModify implements Executable ...@@ -280,7 +280,7 @@ class FindAndModify implements Executable
/** /**
* Create options for executing the command. * Create options for executing the command.
* *
* @see http://php.net/manual/en/mongodb-driver-server.executereadwritecommand.php * @see http://php.net/manual/en/mongodb-driver-server.executewritecommand.php
* @return array * @return array
*/ */
private function createOptions() private function createOptions()
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace MongoDB\Tests\Operation; namespace MongoDB\Tests\Operation;
use MongoDB\Driver\BulkWrite; use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadPreference;
use MongoDB\Model\BSONDocument; use MongoDB\Model\BSONDocument;
use MongoDB\Operation\FindAndModify; use MongoDB\Operation\FindAndModify;
use MongoDB\Tests\CommandObserver; use MongoDB\Tests\CommandObserver;
...@@ -10,6 +12,30 @@ use stdClass; ...@@ -10,6 +12,30 @@ use stdClass;
class FindAndModifyFunctionalTest extends FunctionalTestCase 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() public function testDefaultWriteConcernIsOmitted()
{ {
(new CommandObserver)->observe( (new CommandObserver)->observe(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment