@@ -954,11 +954,11 @@ public function testChangeStreamExample_1_4()
954
954
955
955
$ changeStream ->next ();
956
956
957
- $ nextChange = $ changeStream ->current ();
957
+ $ secondChange = $ changeStream ->current ();
958
958
// End Changestream Example 2
959
959
960
960
$ this ->assertNull ($ firstChange );
961
- $ this ->assertNull ($ nextChange );
961
+ $ this ->assertNull ($ secondChange );
962
962
963
963
$ insertManyResult = $ db ->inventory ->insertMany ([
964
964
['_id ' => 1 , 'x ' => 'foo ' ],
@@ -984,39 +984,42 @@ public function testChangeStreamExample_1_4()
984
984
$ resumeToken = ($ lastChange !== null ) ? $ lastChange ->_id : null ;
985
985
986
986
if ($ resumeToken === null ) {
987
- throw new \Exception ('resumeToken was not found ' );
987
+ throw new \Exception ('Resume token was not found ' );
988
988
}
989
989
990
990
$ changeStream = $ db ->inventory ->watch ([], ['resumeAfter ' => $ resumeToken ]);
991
991
$ changeStream ->rewind ();
992
992
993
- $ nextChange = $ changeStream ->current ();
993
+ $ firstChange = $ changeStream ->current ();
994
994
// End Changestream Example 3
995
995
996
996
$ expectedChange = [
997
- '_id ' => $ nextChange ->_id ,
997
+ '_id ' => $ firstChange ->_id ,
998
998
'operationType ' => 'insert ' ,
999
999
'fullDocument ' => ['_id ' => 2 , 'x ' => 'bar ' ],
1000
1000
'ns ' => ['db ' => $ this ->getDatabaseName (), 'coll ' => 'inventory ' ],
1001
1001
'documentKey ' => ['_id ' => 2 ],
1002
1002
];
1003
1003
1004
- $ this ->assertMatchesDocument ($ expectedChange , $ nextChange );
1004
+ $ this ->assertMatchesDocument ($ expectedChange , $ firstChange );
1005
1005
1006
1006
// Start Changestream Example 4
1007
- $ pipeline = [['$match ' => ['$or ' => [['fullDocument.username ' => 'alice ' ], ['operationType ' => 'delete ' ]]]]];
1007
+ $ pipeline = [
1008
+ ['$match ' => ['fullDocument.username ' => 'alice ' ]],
1009
+ ['$addFields ' => ['newField ' => 'this is an added field! ' ]],
1010
+ ];
1008
1011
$ changeStream = $ db ->inventory ->watch ($ pipeline );
1009
1012
$ changeStream ->rewind ();
1010
1013
1011
1014
$ firstChange = $ changeStream ->current ();
1012
1015
1013
1016
$ changeStream ->next ();
1014
1017
1015
- $ nextChange = $ changeStream ->current ();
1018
+ $ secondChange = $ changeStream ->current ();
1016
1019
// End Changestream Example 4
1017
1020
1018
1021
$ this ->assertNull ($ firstChange );
1019
- $ this ->assertNull ($ nextChange );
1022
+ $ this ->assertNull ($ secondChange );
1020
1023
}
1021
1024
1022
1025
public function testAggregation_example_1 ()
0 commit comments