Skip to content

Commit 6089544

Browse files
committed
Merge branch 'v1.4'
2 parents d63c3fa + 9f45714 commit 6089544

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
@@ -951,11 +951,11 @@ public function testChangeStreamExample_1_4()
951951

952952
$changeStream->next();
953953

954-
$nextChange = $changeStream->current();
954+
$secondChange = $changeStream->current();
955955
// End Changestream Example 2
956956

957957
$this->assertNull($firstChange);
958-
$this->assertNull($nextChange);
958+
$this->assertNull($secondChange);
959959

960960
$insertManyResult = $db->inventory->insertMany([
961961
['_id' => 1, 'x' => 'foo'],
@@ -981,39 +981,42 @@ public function testChangeStreamExample_1_4()
981981
$resumeToken = ($lastChange !== null) ? $lastChange->_id : null;
982982

983983
if ($resumeToken === null) {
984-
throw new \Exception('resumeToken was not found');
984+
throw new \Exception('Resume token was not found');
985985
}
986986

987987
$changeStream = $db->inventory->watch([], ['resumeAfter' => $resumeToken]);
988988
$changeStream->rewind();
989989

990-
$nextChange = $changeStream->current();
990+
$firstChange = $changeStream->current();
991991
// End Changestream Example 3
992992

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

1001-
$this->assertMatchesDocument($expectedChange, $nextChange);
1001+
$this->assertMatchesDocument($expectedChange, $firstChange);
10021002

10031003
// 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+
];
10051008
$changeStream = $db->inventory->watch($pipeline);
10061009
$changeStream->rewind();
10071010

10081011
$firstChange = $changeStream->current();
10091012

10101013
$changeStream->next();
10111014

1012-
$nextChange = $changeStream->current();
1015+
$secondChange = $changeStream->current();
10131016
// End Changestream Example 4
10141017

10151018
$this->assertNull($firstChange);
1016-
$this->assertNull($nextChange);
1019+
$this->assertNull($secondChange);
10171020
}
10181021

10191022
public function testAggregation_example_1()

0 commit comments

Comments
 (0)