Skip to content

Commit cbca068

Browse files
committed
PHPC-1435: Assert against correct error message depending on PHP version
1 parent b0414d5 commit cbca068

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

tests/session/session-startTransaction_error-004.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
--TEST--
2-
MongoDB\Driver\Session::startTransaction() with wrong argument for options array on PHP 7
2+
MongoDB\Driver\Session::startTransaction() with wrong argument for options array on PHP 7.0
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
55
<?php skip_if_not_libmongoc_crypto() ?>
66
<?php skip_if_no_transactions(); ?>
77
<?php skip_if_php_version('<', '7.0.0'); ?>
8+
<?php skip_if_php_version('>=', '7.1.0'); ?>
89
--FILE--
910
<?php
1011
require_once __DIR__ . "/../utils/basic.inc";
@@ -28,7 +29,7 @@ foreach ($options as $txnOptions) {
2829
<?php exit(0); ?>
2930
--EXPECTF--
3031
OK: Got TypeError
31-
Argument 1 passed to MongoDB\Driver\Session::startTransaction() must be of the type array or null, int%S given
32+
Argument 1 passed to MongoDB\Driver\Session::startTransaction() must be of the type array, int%S given
3233
OK: Got TypeError
33-
Argument 1 passed to MongoDB\Driver\Session::startTransaction() must be of the type array or null, object given
34+
Argument 1 passed to MongoDB\Driver\Session::startTransaction() must be of the type array, object given
3435
===DONE===
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
MongoDB\Driver\Session::startTransaction() with wrong argument for options array on PHP 7
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto() ?>
6+
<?php skip_if_no_transactions(); ?>
7+
<?php skip_if_php_version('<', '7.1.0'); ?>
8+
--FILE--
9+
<?php
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
$manager = new MongoDB\Driver\Manager(URI);
13+
$session = $manager->startSession();
14+
15+
$options = [
16+
2,
17+
new stdClass,
18+
];
19+
20+
foreach ($options as $txnOptions) {
21+
echo throws(function () use ($session, $txnOptions) {
22+
$session->startTransaction($txnOptions);
23+
}, TypeError::class), "\n";
24+
}
25+
26+
?>
27+
===DONE===
28+
<?php exit(0); ?>
29+
--EXPECTF--
30+
OK: Got TypeError
31+
Argument 1 passed to MongoDB\Driver\Session::startTransaction() must be of the type array or null, int%S given
32+
OK: Got TypeError
33+
Argument 1 passed to MongoDB\Driver\Session::startTransaction() must be of the type array or null, object given
34+
===DONE===

0 commit comments

Comments
 (0)