Skip to content

Commit fbf318c

Browse files
committed
Merge pull request #861
2 parents 3d48f42 + a1d9c7b commit fbf318c

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
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===

tests/bulk/bulkwrite-update-arrayFilters-001.phpt renamed to tests/bulk/bulkwrite-update-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
MongoDB\Driver\BulkWrite::update with arrayFilters
2+
MongoDB\Driver\BulkWrite::update() with arrayFilters option
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
55
<?php skip_if_not_live(); ?>
@@ -21,7 +21,7 @@ $manager->executeBulkWrite(DATABASE_NAME . '.' . COLLECTION_NAME, $bulk);
2121

2222
$updateBulk = new MongoDB\Driver\BulkWrite();
2323

24-
$query = new MongoDB\Driver\Query(['grades' => ['$gte' => 100]]);
24+
$query = ['grades' => ['$gte' => 100]];
2525
$update = [ '$set' => [ 'grades.$[element]' => 100 ] ];
2626
$options = [
2727
'arrayFilters' => [ [ 'element' => [ '$gte' => 100 ] ] ],
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)