diff --git a/tests/GridFS/BucketFunctionalTest.php b/tests/GridFS/BucketFunctionalTest.php index ccbe6bf02..163c458c2 100644 --- a/tests/GridFS/BucketFunctionalTest.php +++ b/tests/GridFS/BucketFunctionalTest.php @@ -951,8 +951,6 @@ public function testResolveStreamContextForRead(): void fclose($stream); $method = new ReflectionMethod($this->bucket, 'resolveStreamContext'); - $method->setAccessible(true); - $context = $method->invokeArgs($this->bucket, ['gridfs://bucket/filename', 'rb', []]); $this->assertIsArray($context); @@ -967,8 +965,6 @@ public function testResolveStreamContextForRead(): void public function testResolveStreamContextForWrite(): void { $method = new ReflectionMethod($this->bucket, 'resolveStreamContext'); - $method->setAccessible(true); - $context = $method->invokeArgs($this->bucket, ['gridfs://bucket/filename', 'wb', []]); $this->assertIsArray($context); diff --git a/tests/Operation/WatchFunctionalTest.php b/tests/Operation/WatchFunctionalTest.php index cc6690b0f..df4c98fdc 100644 --- a/tests/Operation/WatchFunctionalTest.php +++ b/tests/Operation/WatchFunctionalTest.php @@ -25,6 +25,7 @@ use MongoDB\Operation\InsertOne; use MongoDB\Operation\Watch; use MongoDB\Tests\CommandObserver; +use PHPUnit\Framework\Constraint\ObjectHasProperty; use PHPUnit\Framework\ExpectationFailedException; use ReflectionClass; use stdClass; @@ -724,10 +725,7 @@ public function testInitialCursorIsNotClosed(): void $this->assertNotEquals('0', (string) $changeStream->getCursorId(true)); $rc = new ReflectionClass(ChangeStream::class); - $rp = $rc->getProperty('iterator'); - $rp->setAccessible(true); - - $iterator = $rp->getValue($changeStream); + $iterator = $rc->getProperty('iterator')->getValue($changeStream); $this->assertInstanceOf('IteratorIterator', $iterator); @@ -1225,7 +1223,6 @@ public function testSessionFreed(): void $rc = new ReflectionClass($changeStream); $rp = $rc->getProperty('resumeCallable'); - $rp->setAccessible(true); $this->assertIsCallable($rp->getValue($changeStream)); @@ -1282,9 +1279,9 @@ function (array $event) use (&$aggregateCommands): void { $aggregateCommands[0]['pipeline'][0]->{'$changeStream'}, $this->logicalNot( $this->logicalOr( - $this->objectHasAttribute('resumeAfter'), - $this->objectHasAttribute('startAfter'), - $this->objectHasAttribute('startAtOperationTime'), + new ObjectHasProperty('resumeAfter'), + new ObjectHasProperty('startAfter'), + new ObjectHasProperty('startAtOperationTime'), ), ), ); @@ -1292,9 +1289,9 @@ function (array $event) use (&$aggregateCommands): void { $this->assertThat( $aggregateCommands[1]['pipeline'][0]->{'$changeStream'}, $this->logicalOr( - $this->objectHasAttribute('resumeAfter'), - $this->objectHasAttribute('startAfter'), - $this->objectHasAttribute('startAtOperationTime'), + new ObjectHasProperty('resumeAfter'), + new ObjectHasProperty('startAfter'), + new ObjectHasProperty('startAtOperationTime'), ), );