Skip to content

Commit 933f845

Browse files
committed
Skip causal consistency docs test if no secondary
1 parent e3d90cd commit 933f845

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/DocumentationExamplesTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
use MongoDB\Client;
77
use MongoDB\Database;
88
use MongoDB\Driver\Cursor;
9+
use MongoDB\Driver\ReadPreference;
910
use MongoDB\Driver\Server;
1011
use MongoDB\Driver\WriteConcern;
12+
use MongoDB\Driver\Exception\ConnectionTimeoutException;
1113
use MongoDB\Operation\DropCollection;
1214

1315
/**
@@ -1412,6 +1414,12 @@ function testCausalConsistency()
14121414
{
14131415
$this->skipIfCausalConsistencyIsNotSupported();
14141416

1417+
try {
1418+
$this->manager->selectServer(new ReadPreference('secondary'));
1419+
} catch (ConnectionTimeoutException $e) {
1420+
$this->markTestSkipped('Secondary is not available');
1421+
}
1422+
14151423
// Prep
14161424
$client = new Client(static::getUri());
14171425
$items = $client->selectDatabase(

0 commit comments

Comments
 (0)