Commit 8e88c5c4 authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-454: Remove test dependence on startAtOperationTime

parent db792015
......@@ -402,20 +402,29 @@ class WatchFunctionalTest extends FunctionalTestCase
$this->insertDocument(['_id' => 1]);
/* Insert a document and advance the change stream to ensure we capture
* a resume token. This is necessary when startAtOperationTime is not
* supported (i.e. 3.6 server version). */
$changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSame(0, $changeStream->key());
$this->insertDocument(['_id' => 2]);
/* Killing the cursor and advancing when there is a result will test
* that next()'s resume attempt picks up the latest change. */
$this->killChangeStreamCursor($changeStream);
$changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSame(0, $changeStream->key());
$this->assertSame(1, $changeStream->key());
$expectedResult = [
'_id' => $changeStream->current()->_id,
'operationType' => 'insert',
'fullDocument' => ['_id' => 1],
'fullDocument' => ['_id' => 2],
'ns' => ['db' => $this->getDatabaseName(), 'coll' => $this->getCollectionName()],
'documentKey' => ['_id' => 1],
'documentKey' => ['_id' => 2],
];
$this->assertMatchesDocument($expectedResult, $changeStream->current());
......@@ -428,48 +437,48 @@ class WatchFunctionalTest extends FunctionalTestCase
$changeStream->rewind();
$this->assertTrue($changeStream->valid());
$this->assertSame(0, $changeStream->key());
$this->assertSame(1, $changeStream->key());
$expectedResult = [
'_id' => $changeStream->current()->_id,
'operationType' => 'insert',
'fullDocument' => ['_id' => 1],
'fullDocument' => ['_id' => 2],
'ns' => ['db' => $this->getDatabaseName(), 'coll' => $this->getCollectionName()],
'documentKey' => ['_id' => 1],
'documentKey' => ['_id' => 2],
];
$this->assertMatchesDocument($expectedResult, $changeStream->current());
$this->insertDocument(['_id' => 2]);
$this->insertDocument(['_id' => 3]);
$changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSame(1, $changeStream->key());
$this->assertSame(2, $changeStream->key());
$expectedResult = [
'_id' => $changeStream->current()->_id,
'operationType' => 'insert',
'fullDocument' => ['_id' => 2],
'fullDocument' => ['_id' => 3],
'ns' => ['db' => $this->getDatabaseName(), 'coll' => $this->getCollectionName()],
'documentKey' => ['_id' => 2],
'documentKey' => ['_id' => 3],
];
$this->assertMatchesDocument($expectedResult, $changeStream->current());
$this->killChangeStreamCursor($changeStream);
$this->insertDocument(['_id' => 3]);
$this->insertDocument(['_id' => 4]);
$changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSame(2, $changeStream->key());
$this->assertSame(3, $changeStream->key());
$expectedResult = [
'_id' => $changeStream->current()->_id,
'operationType' => 'insert',
'fullDocument' => ['_id' => 3],
'fullDocument' => ['_id' => 4],
'ns' => ['db' => $this->getDatabaseName(), 'coll' => $this->getCollectionName()],
'documentKey' => ['_id' => 3],
'documentKey' => ['_id' => 4],
];
$this->assertMatchesDocument($expectedResult, $changeStream->current());
......@@ -480,18 +489,18 @@ class WatchFunctionalTest extends FunctionalTestCase
* we'll see {_id: 3} returned again. */
$this->killChangeStreamCursor($changeStream);
$this->insertDocument(['_id' => 4]);
$this->insertDocument(['_id' => 5]);
$changeStream->next();
$this->assertTrue($changeStream->valid());
$this->assertSame(3, $changeStream->key());
$this->assertSame(4, $changeStream->key());
$expectedResult = [
'_id' => $changeStream->current()->_id,
'operationType' => 'insert',
'fullDocument' => ['_id' => 4],
'fullDocument' => ['_id' => 5],
'ns' => ['db' => $this->getDatabaseName(), 'coll' => $this->getCollectionName()],
'documentKey' => ['_id' => 4],
'documentKey' => ['_id' => 5],
];
$this->assertMatchesDocument($expectedResult, $changeStream->current());
......
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