From 22b13617177e6360a4bdc7edfbd84dc57cda88ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 21 May 2024 23:00:39 +0200 Subject: [PATCH] Set readPreference in tests --- src/GridFS/GridFSAdapterTest.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/GridFS/GridFSAdapterTest.php b/src/GridFS/GridFSAdapterTest.php index fee6c566e..1e9867f4a 100644 --- a/src/GridFS/GridFSAdapterTest.php +++ b/src/GridFS/GridFSAdapterTest.php @@ -15,6 +15,7 @@ use League\Flysystem\UnableToWriteFile; use MongoDB\Client; use MongoDB\Database; +use MongoDB\Driver\ReadPreference; use function getenv; /** @@ -146,7 +147,6 @@ public function reading_last_revision(): void $this->runScenario( function () { $this->givenWeHaveAnExistingFile('file.txt', 'version 1'); - usleep(10); $this->givenWeHaveAnExistingFile('file.txt', 'version 2'); $this->assertSame('version 2', $this->adapter()->read('file.txt')); @@ -165,7 +165,6 @@ public function listing_contents_last_revision(bool $deep): void $this->runScenario( function () use ($deep) { $this->givenWeHaveAnExistingFile('file.txt', 'version 1'); - usleep(10); $this->givenWeHaveAnExistingFile('file.txt', 'version 2'); $files = $this->adapter()->listContents('', $deep); @@ -227,9 +226,7 @@ public function move_all_revisions(): void $this->runScenario( function () { $this->givenWeHaveAnExistingFile('file.txt', 'version 1'); - usleep(10); $this->givenWeHaveAnExistingFile('file.txt', 'version 2'); - usleep(10); $this->givenWeHaveAnExistingFile('file.txt', 'version 3'); $this->adapter()->move('file.txt', 'destination.txt', new Config()); @@ -260,7 +257,9 @@ private static function getDatabase(): Database { $uri = getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1:27017/'; - $client = new Client($uri); + $client = new Client($uri, [], [ + 'readPreference' => new ReadPreference(ReadPreference::PRIMARY), + ]); return $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'flysystem_tests'); }