Skip to content

Commit 9f45714

Browse files
committed
Merge pull request #623
2 parents a1852b2 + db84412 commit 9f45714

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/DocumentationExamplesTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -954,11 +954,11 @@ public function testChangeStreamExample_1_4()
954954

955955
$changeStream->next();
956956

957-
$nextChange = $changeStream->current();
957+
$secondChange = $changeStream->current();
958958
// End Changestream Example 2
959959

960960
$this->assertNull($firstChange);
961-
$this->assertNull($nextChange);
961+
$this->assertNull($secondChange);
962962

963963
$insertManyResult = $db->inventory->insertMany([
964964
['_id' => 1, 'x' => 'foo'],
@@ -984,39 +984,42 @@ public function testChangeStreamExample_1_4()
984984
$resumeToken = ($lastChange !== null) ? $lastChange->_id : null;
985985

986986
if ($resumeToken === null) {
987-
throw new \Exception('resumeToken was not found');
987+
throw new \Exception('Resume token was not found');
988988
}
989989

990990
$changeStream = $db->inventory->watch([], ['resumeAfter' => $resumeToken]);
991991
$changeStream->rewind();
992992

993-
$nextChange = $changeStream->current();
993+
$firstChange = $changeStream->current();
994994
// End Changestream Example 3
995995

996996
$expectedChange = [
997-
'_id' => $nextChange->_id,
997+
'_id' => $firstChange->_id,
998998
'operationType' => 'insert',
999999
'fullDocument' => ['_id' => 2, 'x' => 'bar'],
10001000
'ns' => ['db' => $this->getDatabaseName(), 'coll' => 'inventory'],
10011001
'documentKey' => ['_id' => 2],
10021002
];
10031003

1004-
$this->assertMatchesDocument($expectedChange, $nextChange);
1004+
$this->assertMatchesDocument($expectedChange, $firstChange);
10051005

10061006
// 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+
];
10081011
$changeStream = $db->inventory->watch($pipeline);
10091012
$changeStream->rewind();
10101013

10111014
$firstChange = $changeStream->current();
10121015

10131016
$changeStream->next();
10141017

1015-
$nextChange = $changeStream->current();
1018+
$secondChange = $changeStream->current();
10161019
// End Changestream Example 4
10171020

10181021
$this->assertNull($firstChange);
1019-
$this->assertNull($nextChange);
1022+
$this->assertNull($secondChange);
10201023
}
10211024

10221025
public function testAggregation_example_1()

0 commit comments

Comments
 (0)