Skip to content

Commit

Permalink
Fix cursor Id deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Sep 19, 2024
1 parent 3ce4d6a commit aa4f51a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions tests/Model/CodecCursorFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use MongoDB\BSON\Int64;
use MongoDB\Codec\DocumentCodec;
use MongoDB\Driver\CursorId;
use MongoDB\Model\CodecCursor;
use MongoDB\Tests\FunctionalTestCase;

Expand Down Expand Up @@ -55,12 +54,12 @@ function (...$args) use (&$previousErrorHandler, &$deprecations) {
E_USER_DEPRECATED | E_DEPRECATED,
);

$cursorId = $codecCursor->getId();
$cursorId = $codecCursor->getId(true);
} finally {
restore_error_handler();
}

self::assertInstanceOf(CursorId::class, $cursorId);
self::assertInstanceOf(Int64::class, $cursorId);

// Expect 2 deprecations: 1 from CodecCursor, one from Cursor
self::assertCount(2, $deprecations);
Expand Down
6 changes: 3 additions & 3 deletions tests/Operation/WatchFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public function testInitialCursorIsNotClosed(): void
* reports the cursor as alive. While the cursor ID is accessed through
* ChangeStream, we'll need to use reflection to access the internal
* Cursor and call isDead(). */
$this->assertNotEquals('0', (string) $changeStream->getCursorId());
$this->assertNotEquals('0', (string) $changeStream->getCursorId(true));

$rc = new ReflectionClass(ChangeStream::class);
$rp = $rc->getProperty('iterator');
Expand Down Expand Up @@ -1370,11 +1370,11 @@ public function testOriginalReadPreferenceIsPreservedOnResume(): void
}

$changeStream = $operation->execute($secondary);
$previousCursorId = $changeStream->getCursorId();
$previousCursorId = $changeStream->getCursorId(true);
$this->forceChangeStreamResume();

$changeStream->next();
$this->assertNotSame($previousCursorId, $changeStream->getCursorId());
$this->assertNotSame($previousCursorId, $changeStream->getCursorId(true));

$getCursor = Closure::bind(
fn () => $this->iterator->getInnerIterator(),
Expand Down

0 comments on commit aa4f51a

Please sign in to comment.