From e0cc7e6798ed4921ecb7162a3ca348f1ccdd3857 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Fri, 11 Oct 2019 15:26:35 +0200 Subject: [PATCH] PHPC-1391: Prohibit starting a transaction for maxWireVersion < 7 The exeption itself is caused by libmongoc not allowing transactions. This commit only adds tests to protect against regressions --- .../session-startTransaction_error-006.phpt | 26 +++++++++++++++++++ .../session-startTransaction_error-007.phpt | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tests/session/session-startTransaction_error-006.phpt create mode 100644 tests/session/session-startTransaction_error-007.phpt diff --git a/tests/session/session-startTransaction_error-006.phpt b/tests/session/session-startTransaction_error-006.phpt new file mode 100644 index 000000000..0432e38a3 --- /dev/null +++ b/tests/session/session-startTransaction_error-006.phpt @@ -0,0 +1,26 @@ +--TEST-- +MongoDB\Driver\Session::startTransaction() throws an error on replicasets < 4.0 +--SKIPIF-- + + + + +=', '4.0'); ?> +--FILE-- +startSession(); + +echo throws(function () use ($session) { + $session->startTransaction(); +}, MongoDB\Driver\Exception\RuntimeException::class), "\n"; + +?> +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\RuntimeException +Multi-document transactions are not supported by this server version +===DONE=== diff --git a/tests/session/session-startTransaction_error-007.phpt b/tests/session/session-startTransaction_error-007.phpt new file mode 100644 index 000000000..0a82c1b69 --- /dev/null +++ b/tests/session/session-startTransaction_error-007.phpt @@ -0,0 +1,26 @@ +--TEST-- +MongoDB\Driver\Session::startTransaction() throws an error on sharded clusters < 4.2 +--SKIPIF-- + + + + +=', '4.2'); ?> +--FILE-- +startSession(); + +echo throws(function () use ($session) { + $session->startTransaction(); +}, MongoDB\Driver\Exception\RuntimeException::class), "\n"; + +?> +===DONE=== + +--EXPECT-- +OK: Got MongoDB\Driver\Exception\RuntimeException +Multi-document transactions are not supported by this server version +===DONE===