Skip to content

Commit abfae48

Browse files
committed
Merge pull request mongodb#712
2 parents 0f35386 + bbfad48 commit abfae48

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

tests/SpecTests/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class Context
3838
public $defaultWriteOptions = [];
3939

4040
/** @var array */
41-
public $outcomeFindOptions = [];
41+
public $outcomeReadOptions = [];
4242

4343
/** @var string */
4444
public $outcomeCollectionName;
@@ -98,7 +98,7 @@ public static function fromCrud(stdClass $test, $databaseName, $collectionName)
9898
'writeConcern' => new WriteConcern(WriteConcern::MAJORITY),
9999
];
100100

101-
$o->outcomeFindOptions = [
101+
$o->outcomeReadOptions = [
102102
'readConcern' => new ReadConcern('local'),
103103
'readPreference' => new ReadPreference('primary'),
104104
];
@@ -147,7 +147,7 @@ public static function fromTransactions(stdClass $test, $databaseName, $collecti
147147
'writeConcern' => new WriteConcern(WriteConcern::MAJORITY),
148148
];
149149

150-
$o->outcomeFindOptions = [
150+
$o->outcomeReadOptions = [
151151
'readConcern' => new ReadConcern('local'),
152152
'readPreference' => new ReadPreference('primary'),
153153
];

tests/SpecTests/FunctionalTestCase.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ protected static function assertDocumentsMatch($expectedDocument, $actualDocumen
101101
*/
102102
protected function assertOutcomeCollectionData(array $expectedDocuments)
103103
{
104-
$outcomeCollection = $this->getOutcomeCollection();
105-
$findOptions = $this->getContext()->outcomeFindOptions;
104+
$outcomeCollection = $this->getOutcomeCollection($this->getContext()->outcomeReadOptions);
106105

107106
$mi = new MultipleIterator(MultipleIterator::MIT_NEED_ANY);
108107
$mi->attachIterator(new ArrayIterator($expectedDocuments));
109-
$mi->attachIterator(new IteratorIterator($outcomeCollection->find([], $findOptions)));
108+
$mi->attachIterator(new IteratorIterator($outcomeCollection->find()));
110109

111110
foreach ($mi as $documents) {
112111
list($expectedDocument, $actualDocument) = $documents;
@@ -193,16 +192,16 @@ protected function dropTestAndOutcomeCollections()
193192

194193
$collection = null;
195194
if ($context->collectionName !== null) {
196-
$collection = $context->getCollection();
197-
$collection->drop($context->defaultWriteOptions);
195+
$collection = $context->getCollection($context->defaultWriteOptions);
196+
$collection->drop();
198197
}
199198

200199
if ($context->outcomeCollectionName !== null) {
201-
$outcomeCollection = $this->getOutcomeCollection();
200+
$outcomeCollection = $this->getOutcomeCollection($context->defaultWriteOptions);
202201

203202
// Avoid redundant drop if the test and outcome collections are the same
204203
if ($collection === null || $outcomeCollection->getNamespace() !== $collection->getNamespace()) {
205-
$outcomeCollection->drop($context->defaultWriteOptions);
204+
$outcomeCollection->drop();
206205
}
207206
}
208207
}
@@ -226,12 +225,12 @@ protected function insertDataFixtures(array $documents, $collectionName = null)
226225
return;
227226
}
228227

229-
private function getOutcomeCollection()
228+
private function getOutcomeCollection(array $collectionOptions = [])
230229
{
231230
$context = $this->getContext();
232231

233232
// Outcome collection need not use the client under test
234-
return new Collection($this->manager, $context->databaseName, $context->outcomeCollectionName);
233+
return new Collection($this->manager, $context->databaseName, $context->outcomeCollectionName, $collectionOptions);
235234
}
236235

237236
/**

0 commit comments

Comments
 (0)