Skip to content

Commit 6db4790

Browse files
committed
PHPC-1196: Test for unsupported collation and arrayFilters Bulk options
1 parent 3d48f42 commit 6db4790

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
MongoDB\Driver\BulkWrite::delete() collation option requires MongoDB 3.4
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_server_version('>=', '3.4'); ?>
7+
--FILE--
8+
<?php
9+
require_once __DIR__ . "/../utils/basic.inc";
10+
11+
$manager = new MongoDB\Driver\Manager(URI);
12+
13+
$bulk = new MongoDB\Driver\BulkWrite();
14+
15+
$bulk->delete(
16+
['name' => 'foo'],
17+
['collation' => ['locale' => 'en_US']]
18+
);
19+
20+
echo throws(function() use ($manager, $bulk) {
21+
$manager->executeBulkWrite(DATABASE_NAME . '.' . COLLECTION_NAME, $bulk);
22+
}, 'MongoDB\Driver\Exception\RuntimeException'), "\n";
23+
24+
?>
25+
===DONE===
26+
<?php exit(0); ?>
27+
--EXPECT--
28+
OK: Got MongoDB\Driver\Exception\RuntimeException
29+
The selected server does not support collation
30+
===DONE===
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
MongoDB\Driver\BulkWrite::update() collation option requires MongoDB 3.4
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_server_version('>=', '3.4'); ?>
7+
--FILE--
8+
<?php
9+
require_once __DIR__ . "/../utils/basic.inc";
10+
11+
$manager = new MongoDB\Driver\Manager(URI);
12+
13+
$bulk = new MongoDB\Driver\BulkWrite();
14+
15+
$bulk->update(
16+
['name' => 'foo'],
17+
['$inc' => ['size' => 1]],
18+
['collation' => ['locale' => 'en_US']]
19+
);
20+
21+
echo throws(function() use ($manager, $bulk) {
22+
$manager->executeBulkWrite(DATABASE_NAME . '.' . COLLECTION_NAME, $bulk);
23+
}, 'MongoDB\Driver\Exception\RuntimeException'), "\n";
24+
25+
?>
26+
===DONE===
27+
<?php exit(0); ?>
28+
--EXPECT--
29+
OK: Got MongoDB\Driver\Exception\RuntimeException
30+
The selected server does not support collation
31+
===DONE===
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
MongoDB\Driver\BulkWrite::update() arrayFilters option requires MongoDB 3.6
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_server_version('>=', '3.6'); ?>
7+
--FILE--
8+
<?php
9+
require_once __DIR__ . "/../utils/basic.inc";
10+
11+
$manager = new MongoDB\Driver\Manager(URI);
12+
13+
$bulk = new MongoDB\Driver\BulkWrite();
14+
15+
$bulk->update(
16+
['grades' => ['$gte' => 100]],
17+
['$set' => ['grades.$[element]' => 100 ]],
18+
[
19+
'arrayFilters' => [['element' => ['$gte' => 100]]],
20+
'multi' => true,
21+
]
22+
);
23+
24+
echo throws(function() use ($manager, $bulk) {
25+
$manager->executeBulkWrite(DATABASE_NAME . '.' . COLLECTION_NAME, $bulk);
26+
}, 'MongoDB\Driver\Exception\RuntimeException'), "\n";
27+
28+
?>
29+
===DONE===
30+
<?php exit(0); ?>
31+
--EXPECT--
32+
OK: Got MongoDB\Driver\Exception\RuntimeException
33+
The selected server does not support array filters
34+
===DONE===

0 commit comments

Comments
 (0)