|
| 1 | +--TEST-- |
| 2 | +MongoDB\Driver\Server::executeCommand() does not inherit read or write concern |
| 3 | +--SKIPIF-- |
| 4 | +<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> |
| 5 | +<?php skip_if_not_replica_set(); ?> |
| 6 | +<?php skip_if_not_enough_data_nodes(2); /* w:2 */ ?> |
| 7 | +<?php skip_if_server_version('<', '3.6'); /* readConcernLevel:available */ ?> |
| 8 | +<?php skip_if_not_clean(); ?> |
| 9 | +--FILE-- |
| 10 | +<?php |
| 11 | +require_once __DIR__ . "/../utils/basic.inc"; |
| 12 | +require_once __DIR__ . "/../utils/observer.php"; |
| 13 | + |
| 14 | +$manager = new MongoDB\Driver\Manager(URI, ['readConcernLevel' => 'local', 'w' => 2, 'wtimeoutms' => 1000]); |
| 15 | +$server = $manager->selectServer(new MongoDB\Driver\ReadPreference('primary')); |
| 16 | + |
| 17 | +$command = new MongoDB\Driver\Command([ |
| 18 | + 'aggregate' => COLLECTION_NAME, |
| 19 | + 'pipeline' => [ |
| 20 | + ['$group' => ['_id' => 1]], |
| 21 | + ['$out' => COLLECTION_NAME . '.out'], |
| 22 | + ], |
| 23 | + 'cursor' => (object) [], |
| 24 | +]); |
| 25 | + |
| 26 | +(new CommandObserver)->observe( |
| 27 | + function() use ($server, $command) { |
| 28 | + $server->executeCommand(DATABASE_NAME, $command); |
| 29 | + $server->executeCommand(DATABASE_NAME, $command, [ |
| 30 | + 'readConcern' => new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::AVAILABLE), |
| 31 | + 'writeConcern' => new MongoDB\Driver\WriteConcern(1), |
| 32 | + ]); |
| 33 | + }, |
| 34 | + function(stdClass $command) { |
| 35 | + echo json_encode($command->readConcern ?? null), "\n"; |
| 36 | + echo json_encode($command->writeConcern ?? null), "\n"; |
| 37 | + } |
| 38 | +); |
| 39 | + |
| 40 | +?> |
| 41 | +===DONE=== |
| 42 | +<?php exit(0); ?> |
| 43 | +--EXPECT-- |
| 44 | +null |
| 45 | +null |
| 46 | +{"level":"available"} |
| 47 | +{"w":1} |
| 48 | +===DONE=== |
0 commit comments