Commit abfae48c authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #712

parents 0f353869 bbfad489
...@@ -38,7 +38,7 @@ final class Context ...@@ -38,7 +38,7 @@ final class Context
public $defaultWriteOptions = []; public $defaultWriteOptions = [];
/** @var array */ /** @var array */
public $outcomeFindOptions = []; public $outcomeReadOptions = [];
/** @var string */ /** @var string */
public $outcomeCollectionName; public $outcomeCollectionName;
...@@ -98,7 +98,7 @@ final class Context ...@@ -98,7 +98,7 @@ final class Context
'writeConcern' => new WriteConcern(WriteConcern::MAJORITY), 'writeConcern' => new WriteConcern(WriteConcern::MAJORITY),
]; ];
$o->outcomeFindOptions = [ $o->outcomeReadOptions = [
'readConcern' => new ReadConcern('local'), 'readConcern' => new ReadConcern('local'),
'readPreference' => new ReadPreference('primary'), 'readPreference' => new ReadPreference('primary'),
]; ];
...@@ -147,7 +147,7 @@ final class Context ...@@ -147,7 +147,7 @@ final class Context
'writeConcern' => new WriteConcern(WriteConcern::MAJORITY), 'writeConcern' => new WriteConcern(WriteConcern::MAJORITY),
]; ];
$o->outcomeFindOptions = [ $o->outcomeReadOptions = [
'readConcern' => new ReadConcern('local'), 'readConcern' => new ReadConcern('local'),
'readPreference' => new ReadPreference('primary'), 'readPreference' => new ReadPreference('primary'),
]; ];
......
...@@ -101,12 +101,11 @@ class FunctionalTestCase extends BaseFunctionalTestCase ...@@ -101,12 +101,11 @@ class FunctionalTestCase extends BaseFunctionalTestCase
*/ */
protected function assertOutcomeCollectionData(array $expectedDocuments) protected function assertOutcomeCollectionData(array $expectedDocuments)
{ {
$outcomeCollection = $this->getOutcomeCollection(); $outcomeCollection = $this->getOutcomeCollection($this->getContext()->outcomeReadOptions);
$findOptions = $this->getContext()->outcomeFindOptions;
$mi = new MultipleIterator(MultipleIterator::MIT_NEED_ANY); $mi = new MultipleIterator(MultipleIterator::MIT_NEED_ANY);
$mi->attachIterator(new ArrayIterator($expectedDocuments)); $mi->attachIterator(new ArrayIterator($expectedDocuments));
$mi->attachIterator(new IteratorIterator($outcomeCollection->find([], $findOptions))); $mi->attachIterator(new IteratorIterator($outcomeCollection->find()));
foreach ($mi as $documents) { foreach ($mi as $documents) {
list($expectedDocument, $actualDocument) = $documents; list($expectedDocument, $actualDocument) = $documents;
...@@ -193,16 +192,16 @@ class FunctionalTestCase extends BaseFunctionalTestCase ...@@ -193,16 +192,16 @@ class FunctionalTestCase extends BaseFunctionalTestCase
$collection = null; $collection = null;
if ($context->collectionName !== null) { if ($context->collectionName !== null) {
$collection = $context->getCollection(); $collection = $context->getCollection($context->defaultWriteOptions);
$collection->drop($context->defaultWriteOptions); $collection->drop();
} }
if ($context->outcomeCollectionName !== null) { if ($context->outcomeCollectionName !== null) {
$outcomeCollection = $this->getOutcomeCollection(); $outcomeCollection = $this->getOutcomeCollection($context->defaultWriteOptions);
// Avoid redundant drop if the test and outcome collections are the same // Avoid redundant drop if the test and outcome collections are the same
if ($collection === null || $outcomeCollection->getNamespace() !== $collection->getNamespace()) { if ($collection === null || $outcomeCollection->getNamespace() !== $collection->getNamespace()) {
$outcomeCollection->drop($context->defaultWriteOptions); $outcomeCollection->drop();
} }
} }
} }
...@@ -226,12 +225,12 @@ class FunctionalTestCase extends BaseFunctionalTestCase ...@@ -226,12 +225,12 @@ class FunctionalTestCase extends BaseFunctionalTestCase
return; return;
} }
private function getOutcomeCollection() private function getOutcomeCollection(array $collectionOptions = [])
{ {
$context = $this->getContext(); $context = $this->getContext();
// Outcome collection need not use the client under test // Outcome collection need not use the client under test
return new Collection($this->manager, $context->databaseName, $context->outcomeCollectionName); return new Collection($this->manager, $context->databaseName, $context->outcomeCollectionName, $collectionOptions);
} }
/** /**
......
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