Skip to content

Commit 962a9d2

Browse files
committed
PHPC-1875: Session with snapshot=true cannot perform writes
1 parent 6b4eb7c commit 962a9d2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/session/session-004.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
MongoDB\Driver\Session spec test: snapshot option is incompatible with writes
3+
--DESCRIPTION--
4+
PHPC-1875: Disable writes on snapshot sessions
5+
--SKIPIF--
6+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
7+
<?php skip_if_not_libmongoc_crypto(); ?>
8+
<?php skip_if_not_live(); ?>
9+
<?php skip_if_server_version('<', '5.0'); ?>
10+
--FILE--
11+
<?php
12+
require_once __DIR__ . "/../utils/basic.inc";
13+
14+
$manager = create_test_manager();
15+
$session = $manager->startSession(['snapshot' => true]);
16+
17+
$bulk = new MongoDB\Driver\BulkWrite();
18+
$bulk->insert(['x' => 1]);
19+
20+
try {
21+
$manager->executeBulkWrite(NS, $bulk, ['session' => $session]);
22+
} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
23+
/* Note: we intentionally do not assert the server's error message for the
24+
* client specifying a read concern on a write command. It is sufficient to
25+
* assert that the error code is InvalidOptions(72). */
26+
var_dump($e->getCode() === 72);
27+
}
28+
29+
?>
30+
===DONE===
31+
<?php exit(0); ?>
32+
--EXPECT--
33+
bool(true)
34+
===DONE===

0 commit comments

Comments
 (0)