Skip to content

Commit 2d3bd9a

Browse files
committed
Remove and update tests for compatibility
1 parent b6ca9cb commit 2d3bd9a

11 files changed

+17
-175
lines changed

tests/bulkwritecommand/bulkwritecommand-deleteOne_error-004.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo throws(function() use ($bulk) {
1818
// Expected "hint" option to yield string or document but got "array"
1919
echo throws(function() use ($bulk) {
2020
$bulk->deleteOne(NS, [], ['hint' => MongoDB\BSON\PackedArray::fromPHP([])]);
21-
}, MongoDB\Driver\Exception\UnexpectedValueException::class), "\n";
21+
}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n";
2222

2323
?>
2424
===DONE===
@@ -28,6 +28,6 @@ OK: Got MongoDB\Driver\Exception\UnexpectedValueException
2828
MongoDB\BSON\PackedArray cannot be serialized as a root document
2929
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
3030
MongoDB\BSON\PackedArray cannot be serialized as a root document
31-
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
32-
MongoDB\BSON\PackedArray cannot be serialized as a root document
31+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
32+
Expected "hint" option to yield string or document but got "array"
3333
===DONE===
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
--TEST--
2-
MongoDB\Driver\BulkWriteCommand::insertOne() with invalid insert document
2+
MongoDB\Driver\BulkWriteCommand::insertOne() prohibits PackedArray for document
33
--FILE--
44
<?php
55

66
require_once __DIR__ . '/../utils/basic.inc';
77

88
$bulk = new MongoDB\Driver\BulkWriteCommand;
99

10-
// @TODO: FAILED: Expected MongoDB\Driver\Exception\InvalidArgumentException, but no exception thrown!
1110
echo throws(function() use ($bulk) {
12-
$bulk->insertOne(NS, ['' => 1]);
13-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
14-
15-
// @TODO: FAILED: Expected MongoDB\Driver\Exception\InvalidArgumentException, but no exception thrown!
16-
echo throws(function() use ($bulk) {
17-
$bulk->insertOne(NS, ["\xc3\x28" => 1]);
18-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n";
11+
$bulk->insertOne(NS, MongoDB\BSON\PackedArray::fromPHP([]));
12+
}, MongoDB\Driver\Exception\UnexpectedValueException::class), "\n";
1913

2014
?>
2115
===DONE===
2216
<?php exit(0); ?>
2317
--EXPECT--
24-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
25-
invalid document for insert: empty key
26-
27-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
28-
invalid document for insert: corrupt BSON
18+
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
19+
MongoDB\BSON\PackedArray cannot be serialized as a root document
2920
===DONE===

tests/bulkwritecommand/bulkwritecommand-insertOne_error-004.phpt

-20
This file was deleted.

tests/bulkwritecommand/bulkwritecommand-updateOne-001.phpt

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ $manager = create_test_manager();
4040
$document = new MyClass('foo', new MyClass('bar', new MyClass('baz')));
4141

4242
$bulk = new MongoDB\Driver\BulkWriteCommand();
43-
// @TODO: Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Invalid key '__pclass': update only works with $ operators and pipelines
4443
$bulk->updateOne(NS,
4544
['_id' => 'foo'],
46-
$document,
45+
['$set' => $document],
4746
['upsert' => true]
4847
);
4948
$result = $manager->executeBulkWriteCommand($bulk);

tests/bulkwritecommand/bulkwritecommand-updateOne-008.phpt

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class CommandLogger implements MongoDB\Driver\Monitoring\CommandSubscriber
1313
{
1414
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event): void
1515
{
16-
if ($event->getCommandName() !== 'update') {
16+
if ($event->getCommandName() !== 'bulkWrite') {
1717
return;
1818
}
1919

20-
printf("update included sort: %s\n", json_encode($event->getCommand()->updates[0]->sort));
20+
printf("update included sort: %s\n", json_encode($event->getCommand()->ops[0]->sort));
2121
}
2222

2323
public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event): void
@@ -43,9 +43,8 @@ $bulk = new MongoDB\Driver\BulkWriteCommand;
4343
$bulk->updateOne(NS, ['_id' => ['$gt' => 1]], ['$set' => ['x' => 11]], ['sort' => ['_id' => 1]]);
4444
$manager->executeBulkWriteCommand($bulk);
4545

46-
// @TODO: Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Invalid key 'x': update only works with $ operators and pipelines
4746
$bulk = new MongoDB\Driver\BulkWriteCommand;
48-
$bulk->updateOne(NS, ['_id' => ['$gt' => 1]], ['x' => 22], ['sort' => ['_id' => -1]]);
47+
$bulk->updateOne(NS, ['_id' => ['$gt' => 1]], ['$set' => ['x' => 22]], ['sort' => ['_id' => -1]]);
4948
$manager->executeBulkWriteCommand($bulk);
5049

5150
$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query([]));

tests/bulkwritecommand/bulkwritecommand-updateOne_error-001.phpt

-29
This file was deleted.

tests/bulkwritecommand/bulkwritecommand-updateOne_error-002.phpt

-41
This file was deleted.

tests/bulkwritecommand/bulkwritecommand-updateOne_error-003.phpt

+2-11
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ require_once __DIR__ . '/../utils/basic.inc';
77

88
$bulk = new MongoDB\Driver\BulkWriteCommand;
99

10-
// @TODO: Invalid key 'y': update only works with $ operators and pipelines
1110
echo throws(function() use ($bulk) {
12-
$bulk->updateOne(NS, ['x' => 1], ['y' => 1], ['multi' => true]);
13-
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
14-
15-
echo throws(function() use ($bulk) {
16-
$bulk->updateOne(NS, ['x' => 1], ['y' => 1], ['collation' => 1]);
11+
$bulk->updateOne(NS, ['x' => 1], ['$set' => ['y' => 1]], ['collation' => 1]);
1712
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
1813

1914
echo throws(function() use ($bulk) {
@@ -24,7 +19,6 @@ echo throws(function() use ($bulk) {
2419
$bulk->updateOne(NS, ['x' => 1], ['$set' => ['y' => 1]], ['arrayFilters' => 1]);
2520
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
2621

27-
// @TODO: Expected "arrayFilters" option to yield array but got non-sequential keys
2822
echo throws(function() use ($bulk) {
2923
$bulk->updateOne(NS, ['x' => 1], ['$set' => ['y' => 1]], ['arrayFilters' => ['foo' => 'bar']]);
3024
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n\n";
@@ -37,9 +31,6 @@ echo throws(function() use ($bulk) {
3731
===DONE===
3832
<?php exit(0); ?>
3933
--EXPECT--
40-
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
41-
Replacement document conflicts with true "multi" option
42-
4334
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
4435
Expected "collation" option to be array or object, int given
4536

@@ -50,7 +41,7 @@ OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5041
Expected "arrayFilters" option to be array or object, int given
5142

5243
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
53-
"arrayFilters" option has invalid keys for a BSON array
44+
Expected "arrayFilters" option to yield array but got non-sequential keys
5445

5546
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5647
Expected "hint" option to be string, array, or object, int given

tests/bulkwritecommand/bulkwritecommand-updateOne_error-006.phpt

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ echo throws(function() use ($bulk) {
1414
$bulk->updateOne(NS, [], [], ['collation' => MongoDB\BSON\PackedArray::fromPHP([])]);
1515
}, MongoDB\Driver\Exception\UnexpectedValueException::class), "\n";
1616

17-
// @TODO: ALMOST: Got MongoDB\Driver\Exception\InvalidArgumentException - expected MongoDB\Driver\Exception\UnexpectedValueException
18-
// Expected "hint" option to yield string or document but got "array"
1917
echo throws(function() use ($bulk) {
2018
$bulk->updateOne(NS, [], [], ['hint' => MongoDB\BSON\PackedArray::fromPHP([])]);
21-
}, MongoDB\Driver\Exception\UnexpectedValueException::class), "\n";
19+
}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n";
2220

2321
?>
2422
===DONE===
@@ -28,6 +26,6 @@ OK: Got MongoDB\Driver\Exception\UnexpectedValueException
2826
MongoDB\BSON\PackedArray cannot be serialized as a root document
2927
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
3028
MongoDB\BSON\PackedArray cannot be serialized as a root document
31-
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
32-
MongoDB\BSON\PackedArray cannot be serialized as a root document
29+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
30+
Expected "hint" option to yield string or document but got "array"
3331
===DONE===

tests/bulkwritecommand/bulkwritecommand-updateOne_error-008.phpt

-23
This file was deleted.

tests/bulkwritecommand/bulkwritecommand-updateOne_error-009.phpt

-23
This file was deleted.

0 commit comments

Comments
 (0)