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