PHPLIB-466: Fix usage of useMultipleMongoses in spec tests

parent 1245eb94
...@@ -121,7 +121,7 @@ final class Context ...@@ -121,7 +121,7 @@ final class Context
return $o; return $o;
} }
public static function fromRetryableWrites(stdClass $test, $databaseName, $collectionName) public static function fromRetryableWrites(stdClass $test, $databaseName, $collectionName, $useMultipleMongoses)
{ {
$o = new self($databaseName, $collectionName); $o = new self($databaseName, $collectionName);
...@@ -134,12 +134,12 @@ final class Context ...@@ -134,12 +134,12 @@ final class Context
$o->outcomeCollectionName = $test->outcome->collection->name; $o->outcomeCollectionName = $test->outcome->collection->name;
} }
$o->client = new Client(FunctionalTestCase::getUri(), $clientOptions); $o->client = new Client(FunctionalTestCase::getUri($useMultipleMongoses), $clientOptions);
return $o; return $o;
} }
public static function fromTransactions(stdClass $test, $databaseName, $collectionName) public static function fromTransactions(stdClass $test, $databaseName, $collectionName, $useMultipleMongoses)
{ {
$o = new self($databaseName, $collectionName); $o = new self($databaseName, $collectionName);
...@@ -159,7 +159,7 @@ final class Context ...@@ -159,7 +159,7 @@ final class Context
* re-using a previously persisted libmongoc client object. */ * re-using a previously persisted libmongoc client object. */
$clientOptions += ['p' => mt_rand()]; $clientOptions += ['p' => mt_rand()];
$o->client = new Client(FunctionalTestCase::getUri(), $clientOptions); $o->client = new Client(FunctionalTestCase::getUri($useMultipleMongoses), $clientOptions);
$session0Options = isset($test->sessionOptions->session0) ? (array) $test->sessionOptions->session0 : []; $session0Options = isset($test->sessionOptions->session0) ? (array) $test->sessionOptions->session0 : [];
$session1Options = isset($test->sessionOptions->session1) ? (array) $test->sessionOptions->session1 : []; $session1Options = isset($test->sessionOptions->session1) ? (array) $test->sessionOptions->session1 : [];
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace MongoDB\Tests\SpecTests; namespace MongoDB\Tests\SpecTests;
use MongoDB\Driver\Manager;
use stdClass; use stdClass;
use function basename; use function basename;
use function file_get_contents; use function file_get_contents;
...@@ -29,15 +28,13 @@ class RetryableWritesSpecTest extends FunctionalTestCase ...@@ -29,15 +28,13 @@ class RetryableWritesSpecTest extends FunctionalTestCase
$this->markTestSkipped('Transaction numbers are only allowed on a replica set member or mongos (PHPC-1415)'); $this->markTestSkipped('Transaction numbers are only allowed on a replica set member or mongos (PHPC-1415)');
} }
if (isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isShardedCluster()) { $useMultipleMongoses = isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isShardedCluster();
$this->manager = new Manager(static::getUri(true));
}
if (isset($runOn)) { if (isset($runOn)) {
$this->checkServerRequirements($runOn); $this->checkServerRequirements($runOn);
} }
$context = Context::fromRetryableWrites($test, $this->getDatabaseName(), $this->getCollectionName()); $context = Context::fromRetryableWrites($test, $this->getDatabaseName(), $this->getCollectionName(), $useMultipleMongoses);
$this->setContext($context); $this->setContext($context);
$this->dropTestAndOutcomeCollections(); $this->dropTestAndOutcomeCollections();
......
...@@ -135,9 +135,7 @@ class TransactionsSpecTest extends FunctionalTestCase ...@@ -135,9 +135,7 @@ class TransactionsSpecTest extends FunctionalTestCase
$this->markTestSkipped($test->skipReason); $this->markTestSkipped($test->skipReason);
} }
if (isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isShardedCluster()) { $useMultipleMongoses = isset($test->useMultipleMongoses) && $test->useMultipleMongoses && $this->isShardedCluster();
$this->manager = new Manager(static::getUri(true));
}
if (isset($runOn)) { if (isset($runOn)) {
$this->checkServerRequirements($runOn); $this->checkServerRequirements($runOn);
...@@ -150,7 +148,7 @@ class TransactionsSpecTest extends FunctionalTestCase ...@@ -150,7 +148,7 @@ class TransactionsSpecTest extends FunctionalTestCase
$databaseName = isset($databaseName) ? $databaseName : $this->getDatabaseName(); $databaseName = isset($databaseName) ? $databaseName : $this->getDatabaseName();
$collectionName = isset($collectionName) ? $collectionName : $this->getCollectionName(); $collectionName = isset($collectionName) ? $collectionName : $this->getCollectionName();
$context = Context::fromTransactions($test, $databaseName, $collectionName); $context = Context::fromTransactions($test, $databaseName, $collectionName, $useMultipleMongoses);
$this->setContext($context); $this->setContext($context);
$this->dropTestAndOutcomeCollections(); $this->dropTestAndOutcomeCollections();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment