From aa4f51a197a0ff231bc696f4e6cd250c9e8ea97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 19 Sep 2024 08:55:37 +0200 Subject: [PATCH] Fix cursor Id deprecation --- tests/Model/CodecCursorFunctionalTest.php | 5 ++--- tests/Operation/WatchFunctionalTest.php | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/Model/CodecCursorFunctionalTest.php b/tests/Model/CodecCursorFunctionalTest.php index 432d71732..c66146b32 100644 --- a/tests/Model/CodecCursorFunctionalTest.php +++ b/tests/Model/CodecCursorFunctionalTest.php @@ -4,7 +4,6 @@ use MongoDB\BSON\Int64; use MongoDB\Codec\DocumentCodec; -use MongoDB\Driver\CursorId; use MongoDB\Model\CodecCursor; use MongoDB\Tests\FunctionalTestCase; @@ -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); diff --git a/tests/Operation/WatchFunctionalTest.php b/tests/Operation/WatchFunctionalTest.php index 562192f1b..639199471 100644 --- a/tests/Operation/WatchFunctionalTest.php +++ b/tests/Operation/WatchFunctionalTest.php @@ -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'); @@ -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(),