2
2
3
3
namespace MongoDB \Tests \Operation ;
4
4
5
+ use MongoDB \BSON \Document ;
5
6
use MongoDB \BSON \Javascript ;
6
7
use MongoDB \BSON \ObjectId ;
7
8
use MongoDB \Exception \InvalidArgumentException ;
9
+ use MongoDB \Model \BSONDocument ;
8
10
use MongoDB \Operation \MapReduce ;
9
11
use stdClass ;
10
12
@@ -25,6 +27,31 @@ public function provideInvalidOutValues()
25
27
return $ this ->wrapValuesForDataProvider ([123 , 3.14 , true ]);
26
28
}
27
29
30
+ /** @dataProvider provideDeprecatedOutValues */
31
+ public function testConstructorOutArgumentDeprecations ($ out ): void
32
+ {
33
+ $ map = new Javascript ('function() { emit(this.x, this.y); } ' );
34
+ $ reduce = new Javascript ('function(key, values) { return Array.sum(values); } ' );
35
+
36
+ $ this ->assertDeprecated (function () use ($ map , $ reduce , $ out ): void {
37
+ new MapReduce ($ this ->getDatabaseName (), $ this ->getCollectionName (), $ map , $ reduce , $ out );
38
+ });
39
+ }
40
+
41
+ public function provideDeprecatedOutValues (): array
42
+ {
43
+ return [
44
+ 'nonAtomic:array ' => [['nonAtomic ' => false ]],
45
+ 'nonAtomic:object ' => [(object ) ['nonAtomic ' => false ]],
46
+ 'nonAtomic:Serializable ' => [new BSONDocument (['nonAtomic ' => false ])],
47
+ 'nonAtomic:Document ' => [Document::fromPHP (['nonAtomic ' => false ])],
48
+ 'sharded:array ' => [['sharded ' => false ]],
49
+ 'sharded:object ' => [(object ) ['sharded ' => false ]],
50
+ 'sharded:Serializable ' => [new BSONDocument (['sharded ' => false ])],
51
+ 'sharded:Document ' => [Document::fromPHP (['sharded ' => false ])],
52
+ ];
53
+ }
54
+
28
55
/** @dataProvider provideInvalidConstructorOptions */
29
56
public function testConstructorOptionTypeChecks (array $ options ): void
30
57
{
0 commit comments