Commit 306e5688 authored by Jeremy Mikola's avatar Jeremy Mikola

Start iteration with rewind() in ChangeStream::key() test

Previously, iteration started with next(), so the first element's key was 1. Iteration should being with rewind() and the initial key should be zero.

With this change, we're still testing that the key is only incremented when next() successfully increments.
parent a49d6e52
......@@ -180,13 +180,14 @@ class WatchFunctionalTest extends FunctionalTestCase
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());
$this->assertFalse($changeStream->valid());
$this->assertNull($changeStream->key());
$this->insertDocument(['_id' => 1, 'x' => 'foo']);
$changeStream->next();
$changeStream->rewind();
$this->assertTrue($changeStream->valid());
$this->assertSame(1, $changeStream->key());
$this->assertSame(0, $changeStream->key());
$changeStream->next();
$this->assertFalse($changeStream->valid());
......@@ -206,7 +207,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSame(2, $changeStream->key());
$this->assertSame(1, $changeStream->key());
}
public function testNonEmptyPipeline()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment