17
17
18
18
class WatchFunctionalTest extends FunctionalTestCase
19
19
{
20
+ private $ defaultOptions = ['maxAwaitTimeMS ' => 100 ];
21
+
20
22
public function setUp ()
21
23
{
22
24
parent ::setUp ();
@@ -34,7 +36,7 @@ public function testNextResumesAfterCursorNotFound()
34
36
{
35
37
$ this ->insertDocument (['_id ' => 1 , 'x ' => 'foo ' ]);
36
38
37
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
39
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
38
40
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
39
41
40
42
$ changeStream ->rewind ();
@@ -81,7 +83,7 @@ public function testNextResumesAfterConnectionException()
81
83
$ manager = new Manager ($ this ->getUri (), ['socketTimeoutMS ' => 50 ]);
82
84
$ primaryServer = $ manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
83
85
84
- $ operation = new Watch ($ manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
86
+ $ operation = new Watch ($ manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
85
87
$ changeStream = $ operation ->execute ($ primaryServer );
86
88
87
89
/* Note: we intentionally do not start iteration with rewind() to ensure
@@ -134,7 +136,7 @@ public function testRewindResumesAfterConnectionException()
134
136
$ manager = new Manager ($ this ->getUri (), ['socketTimeoutMS ' => 50 ]);
135
137
$ primaryServer = $ manager ->selectServer (new ReadPreference (ReadPreference::RP_PRIMARY ));
136
138
137
- $ operation = new Watch ($ manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
139
+ $ operation = new Watch ($ manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
138
140
$ changeStream = $ operation ->execute ($ primaryServer );
139
141
140
142
$ commands = [];
@@ -180,7 +182,7 @@ public function testNoChangeAfterResumeBeforeInsert()
180
182
{
181
183
$ this ->insertDocument (['_id ' => 1 , 'x ' => 'foo ' ]);
182
184
183
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
185
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
184
186
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
185
187
186
188
$ changeStream ->rewind ();
@@ -225,7 +227,7 @@ public function testNoChangeAfterResumeBeforeInsert()
225
227
226
228
public function testKey ()
227
229
{
228
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
230
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
229
231
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
230
232
231
233
$ this ->assertFalse ($ changeStream ->valid ());
@@ -262,7 +264,7 @@ public function testNonEmptyPipeline()
262
264
{
263
265
$ pipeline = [['$project ' => ['foo ' => [0 ]]]];
264
266
265
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , [ ' maxAwaitTimeMS ' => 100 ] );
267
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , $ this -> defaultOptions );
266
268
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
267
269
268
270
$ this ->insertDocument (['_id ' => 1 ]);
@@ -313,7 +315,7 @@ public function testNextResumeTokenNotFound()
313
315
{
314
316
$ pipeline = [['$project ' => ['_id ' => 0 ]]];
315
317
316
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , [ ' maxAwaitTimeMS ' => 100 ] );
318
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , $ this -> defaultOptions );
317
319
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
318
320
319
321
/* Note: we intentionally do not start iteration with rewind() to ensure
@@ -331,7 +333,7 @@ public function testRewindResumeTokenNotFound()
331
333
{
332
334
$ pipeline = [['$project ' => ['_id ' => 0 ]]];
333
335
334
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , [ ' maxAwaitTimeMS ' => 100 ] );
336
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , $ this -> defaultOptions );
335
337
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
336
338
337
339
$ this ->insertDocument (['x ' => 1 ]);
@@ -347,7 +349,7 @@ public function testNextResumeTokenInvalidType()
347
349
{
348
350
$ pipeline = [['$project ' => ['_id ' => ['$literal ' => 'foo ' ]]]];
349
351
350
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , [ ' maxAwaitTimeMS ' => 100 ] );
352
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , $ this -> defaultOptions );
351
353
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
352
354
353
355
/* Note: we intentionally do not start iteration with rewind() to ensure
@@ -365,7 +367,7 @@ public function testRewindResumeTokenInvalidType()
365
367
{
366
368
$ pipeline = [['$project ' => ['_id ' => ['$literal ' => 'foo ' ]]]];
367
369
368
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , [ ' maxAwaitTimeMS ' => 100 ] );
370
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), $ pipeline , $ this -> defaultOptions );
369
371
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
370
372
371
373
$ this ->insertDocument (['x ' => 1 ]);
@@ -424,7 +426,7 @@ public function testMaxAwaitTimeMS()
424
426
425
427
public function testRewindResumesAfterCursorNotFound ()
426
428
{
427
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
429
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
428
430
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
429
431
430
432
$ this ->killChangeStreamCursor ($ changeStream );
@@ -436,7 +438,7 @@ public function testRewindResumesAfterCursorNotFound()
436
438
437
439
public function testRewindExtractsResumeTokenAndNextResumes ()
438
440
{
439
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], [ ' maxAwaitTimeMS ' => 100 ] );
441
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], $ this -> defaultOptions );
440
442
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
441
443
442
444
$ this ->insertDocument (['_id ' => 1 , 'x ' => 'foo ' ]);
@@ -473,7 +475,7 @@ public function testRewindExtractsResumeTokenAndNextResumes()
473
475
*/
474
476
public function testTypeMapOption (array $ typeMap , $ expectedChangeDocument )
475
477
{
476
- $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], ['maxAwaitTimeMS ' => 100 , ' typeMap ' => $ typeMap ]);
478
+ $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], ['typeMap ' => $ typeMap ] + $ this -> defaultOptions );
477
479
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
478
480
479
481
$ changeStream ->rewind ();
0 commit comments