Skip to content

Commit 7d5b784

Browse files
committed
Revise variable names and error message in change stream examples
1 parent a1852b2 commit 7d5b784

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/DocumentationExamplesTest.php

Lines changed: 8 additions & 8 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,24 +984,24 @@ 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
10071007
$pipeline = [['$match' => ['$or' => [['fullDocument.username' => 'alice'], ['operationType' => 'delete']]]]];
@@ -1012,11 +1012,11 @@ public function testChangeStreamExample_1_4()
10121012

10131013
$changeStream->next();
10141014

1015-
$nextChange = $changeStream->current();
1015+
$secondChange = $changeStream->current();
10161016
// End Changestream Example 4
10171017

10181018
$this->assertNull($firstChange);
1019-
$this->assertNull($nextChange);
1019+
$this->assertNull($secondChange);
10201020
}
10211021

10221022
public function testAggregation_example_1()

0 commit comments

Comments
 (0)