Skip to content

Commit 67a17ed

Browse files
committed
Remove skipped tests for pre-3.6 servers
1 parent 8b9d47b commit 67a17ed

30 files changed

+11
-367
lines changed

tests/ClientFunctionalTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use function call_user_func;
1313
use function is_callable;
1414
use function sprintf;
15-
use function version_compare;
1615

1716
/**
1817
* Functional tests for the Client class.
@@ -122,10 +121,6 @@ private function assertDatabaseExists(string $databaseName, ?callable $callback
122121

123122
public function testStartSession(): void
124123
{
125-
if (version_compare($this->getFeatureCompatibilityVersion(), '3.6', '<')) {
126-
$this->markTestSkipped('startSession() is only supported on FCV 3.6 or higher');
127-
}
128-
129124
$this->assertInstanceOf(Session::class, $this->client->startSession());
130125
}
131126
}

tests/Collection/CollectionFunctionalTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ public function testAggregateWithinTransaction(): void
147147

148148
public function testCreateIndexSplitsCommandOptions(): void
149149
{
150-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
151-
$this->markTestSkipped('Sessions are not supported');
152-
}
153-
154150
(new CommandObserver())->observe(
155151
function (): void {
156152
$this->collection->createIndex(

tests/DocumentationExamplesTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,10 +1135,6 @@ public function testAggregation_example_3(): void
11351135

11361136
public function testAggregation_example_4(): void
11371137
{
1138-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
1139-
$this->markTestSkipped('$lookup does not support "let" option');
1140-
}
1141-
11421138
$db = new Database($this->manager, $this->getDatabaseName());
11431139

11441140
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps

tests/FunctionalTestCase.php

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,7 @@ public function configureFailPoint($command, ?Server $server = null): void
294294
*/
295295
protected function createCollection(array $options = []): void
296296
{
297-
if (version_compare($this->getServerVersion(), '3.4.0', '>=')) {
298-
$options += ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)];
299-
}
297+
$options += ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)];
300298

301299
$operation = new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), $options);
302300
$operation->execute($this->getPrimaryServer());
@@ -313,9 +311,7 @@ protected function createCollection(array $options = []): void
313311
*/
314312
protected function dropCollection(array $options = []): void
315313
{
316-
if (version_compare($this->getServerVersion(), '3.4.0', '>=')) {
317-
$options += ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)];
318-
}
314+
$options += ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)];
319315

320316
$operation = new DropCollection($this->getDatabaseName(), $this->getCollectionName(), $options);
321317
$operation->execute($this->getPrimaryServer());
@@ -327,10 +323,6 @@ protected function getFeatureCompatibilityVersion(?ReadPreference $readPreferenc
327323
return $this->getServerVersion($readPreference);
328324
}
329325

330-
if (version_compare($this->getServerVersion(), '3.4.0', '<')) {
331-
return $this->getServerVersion($readPreference);
332-
}
333-
334326
$cursor = $this->manager->executeCommand(
335327
'admin',
336328
new Command(['getParameter' => 1, 'featureCompatibilityVersion' => 1]),
@@ -340,16 +332,10 @@ protected function getFeatureCompatibilityVersion(?ReadPreference $readPreferenc
340332
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
341333
$document = current($cursor->toArray());
342334

343-
// MongoDB 3.6: featureCompatibilityVersion is an embedded document
344335
if (isset($document['featureCompatibilityVersion']['version']) && is_string($document['featureCompatibilityVersion']['version'])) {
345336
return $document['featureCompatibilityVersion']['version'];
346337
}
347338

348-
// MongoDB 3.4: featureCompatibilityVersion is a string
349-
if (isset($document['featureCompatibilityVersion']) && is_string($document['featureCompatibilityVersion'])) {
350-
return $document['featureCompatibilityVersion'];
351-
}
352-
353339
throw new UnexpectedValueException('Could not determine featureCompatibilityVersion');
354340
}
355341

@@ -463,21 +449,13 @@ protected function skipIfChangeStreamIsNotSupported(): void
463449
switch ($this->getPrimaryServer()->getType()) {
464450
case Server::TYPE_MONGOS:
465451
case Server::TYPE_LOAD_BALANCER:
466-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
467-
$this->markTestSkipped('$changeStream is only supported on MongoDB 3.6 or higher');
468-
}
469-
470452
if (! $this->isShardedClusterUsingReplicasets()) {
471453
$this->markTestSkipped('$changeStream is only supported with replicasets');
472454
}
473455

474456
break;
475457

476458
case Server::TYPE_RS_PRIMARY:
477-
if (version_compare($this->getFeatureCompatibilityVersion(), '3.6', '<')) {
478-
$this->markTestSkipped('$changeStream is only supported on FCV 3.6 or higher');
479-
}
480-
481459
break;
482460

483461
default:
@@ -490,21 +468,13 @@ protected function skipIfCausalConsistencyIsNotSupported(): void
490468
switch ($this->getPrimaryServer()->getType()) {
491469
case Server::TYPE_MONGOS:
492470
case Server::TYPE_LOAD_BALANCER:
493-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
494-
$this->markTestSkipped('Causal Consistency is only supported on MongoDB 3.6 or higher');
495-
}
496-
497471
if (! $this->isShardedClusterUsingReplicasets()) {
498472
$this->markTestSkipped('Causal Consistency is only supported with replicasets');
499473
}
500474

501475
break;
502476

503477
case Server::TYPE_RS_PRIMARY:
504-
if (version_compare($this->getFeatureCompatibilityVersion(), '3.6', '<')) {
505-
$this->markTestSkipped('Causal Consistency is only supported on FCV 3.6 or higher');
506-
}
507-
508478
if ($this->getServerStorageEngine() !== 'wiredTiger') {
509479
$this->markTestSkipped('Causal Consistency requires WiredTiger storage engine');
510480
}

tests/Model/IndexInfoFunctionalTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use MongoDB\Collection;
66
use MongoDB\Tests\FunctionalTestCase;
77

8-
use function version_compare;
9-
108
class IndexInfoFunctionalTest extends FunctionalTestCase
119
{
1210
/** @var Collection */
@@ -43,8 +41,8 @@ public function testIs2dSphere(): void
4341
$this->assertEquals($indexName, $index->getName());
4442
$this->assertTrue($index->is2dSphere());
4543

46-
$expectedVersion = version_compare($this->getServerVersion(), '3.2.0', '<') ? 2 : 3;
47-
$this->assertEquals($expectedVersion, $index['2dsphereIndexVersion']);
44+
// MongoDB 3.2+ reports index version 3
45+
$this->assertEquals(3, $index['2dsphereIndexVersion']);
4846
}
4947

5048
/**
@@ -82,8 +80,8 @@ public function testIsText(): void
8280
$this->assertEquals('english', $index['default_language']);
8381
$this->assertEquals('language', $index['language_override']);
8482

85-
$expectedVersion = version_compare($this->getServerVersion(), '3.2.0', '<') ? 2 : 3;
86-
$this->assertEquals($expectedVersion, $index['textIndexVersion']);
83+
// MongoDB 3.2+ reports index version 3
84+
$this->assertEquals(3, $index['textIndexVersion']);
8785

8886
$this->assertSameDocument(['x' => 1], $index['weights']);
8987
}

tests/Operation/AggregateFunctionalTest.php

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MongoDB\Tests\Operation;
44

5-
use ArrayIterator;
65
use MongoDB\Collection;
76
use MongoDB\Driver\BulkWrite;
87
use MongoDB\Driver\Exception\RuntimeException;
@@ -14,7 +13,6 @@
1413

1514
use function current;
1615
use function iterator_to_array;
17-
use function version_compare;
1816

1917
class AggregateFunctionalTest extends FunctionalTestCase
2018
{
@@ -60,10 +58,6 @@ function (array $event): void {
6058

6159
public function testCurrentOpCommand(): void
6260
{
63-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
64-
$this->markTestSkipped('$currentOp is not supported');
65-
}
66-
6761
(new CommandObserver())->observe(
6862
function (): void {
6963
$operation = new Aggregate(
@@ -146,10 +140,6 @@ public function testUnrecognizedPipelineState(): void
146140

147141
public function testSessionOption(): void
148142
{
149-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
150-
$this->markTestSkipped('Sessions are not supported');
151-
}
152-
153143
(new CommandObserver())->observe(
154144
function (): void {
155145
$operation = new Aggregate(
@@ -182,26 +172,6 @@ public function testTypeMapOption(?array $typeMap, array $expectedDocuments): vo
182172
$this->assertEquals($expectedDocuments, $results);
183173
}
184174

185-
/**
186-
* @dataProvider provideTypeMapOptionsAndExpectedDocuments
187-
*/
188-
public function testTypeMapOptionWithoutCursor(?array $typeMap, array $expectedDocuments): void
189-
{
190-
if (version_compare($this->getServerVersion(), '3.6.0', '>=')) {
191-
$this->markTestSkipped('Aggregations with useCursor == false are not supported');
192-
}
193-
194-
$this->createFixtures(3);
195-
196-
$pipeline = [['$match' => ['_id' => ['$ne' => 2]]]];
197-
198-
$operation = new Aggregate($this->getDatabaseName(), $this->getCollectionName(), $pipeline, ['typeMap' => $typeMap, 'useCursor' => false]);
199-
$results = $operation->execute($this->getPrimaryServer());
200-
201-
$this->assertInstanceOf(ArrayIterator::class, $results);
202-
$this->assertEquals($expectedDocuments, iterator_to_array($results));
203-
}
204-
205175
public function testExplainOption(): void
206176
{
207177
$this->createFixtures(3);
@@ -222,10 +192,6 @@ public function testExplainOption(): void
222192

223193
public function testExplainOptionWithWriteConcern(): void
224194
{
225-
if (version_compare($this->getServerVersion(), '3.4.0', '<')) {
226-
$this->markTestSkipped('The writeConcern option is not supported');
227-
}
228-
229195
$this->createFixtures(3);
230196

231197
$pipeline = [['$match' => ['_id' => ['$ne' => 2]]], ['$out' => $this->getCollectionName() . '.output']];
@@ -258,10 +224,6 @@ function (array $event): void {
258224

259225
public function testBypassDocumentValidationSetWhenTrue(): void
260226
{
261-
if (version_compare($this->getServerVersion(), '3.2.0', '<')) {
262-
$this->markTestSkipped('bypassDocumentValidation is not supported');
263-
}
264-
265227
(new CommandObserver())->observe(
266228
function (): void {
267229
$operation = new Aggregate(
@@ -282,10 +244,6 @@ function (array $event): void {
282244

283245
public function testBypassDocumentValidationUnsetWhenFalse(): void
284246
{
285-
if (version_compare($this->getServerVersion(), '3.2.0', '<')) {
286-
$this->markTestSkipped('bypassDocumentValidation is not supported');
287-
}
288-
289247
(new CommandObserver())->observe(
290248
function (): void {
291249
$operation = new Aggregate(

tests/Operation/BulkWriteFunctionalTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ public function testUnacknowledgedWriteConcernAccessesUpsertedIds(BulkWriteResul
225225

226226
public function testSessionOption(): void
227227
{
228-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
229-
$this->markTestSkipped('Sessions are not supported');
230-
}
231-
232228
(new CommandObserver())->observe(
233229
function (): void {
234230
$operation = new BulkWrite(
@@ -248,10 +244,6 @@ function (array $event): void {
248244

249245
public function testBypassDocumentValidationSetWhenTrue(): void
250246
{
251-
if (version_compare($this->getServerVersion(), '3.2.0', '<')) {
252-
$this->markTestSkipped('bypassDocumentValidation is not supported');
253-
}
254-
255247
(new CommandObserver())->observe(
256248
function (): void {
257249
$operation = new BulkWrite(
@@ -272,10 +264,6 @@ function (array $event): void {
272264

273265
public function testBypassDocumentValidationUnsetWhenFalse(): void
274266
{
275-
if (version_compare($this->getServerVersion(), '3.2.0', '<')) {
276-
$this->markTestSkipped('bypassDocumentValidation is not supported');
277-
}
278-
279267
(new CommandObserver())->observe(
280268
function (): void {
281269
$operation = new BulkWrite(

tests/Operation/CountFunctionalTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use MongoDB\Operation\InsertMany;
88
use MongoDB\Tests\CommandObserver;
99

10-
use function version_compare;
11-
1210
class CountFunctionalTest extends FunctionalTestCase
1311
{
1412
public function testDefaultReadConcernIsOmitted(): void
@@ -50,12 +48,8 @@ public function testHintOption(): void
5048
'sparse_x',
5149
];
5250

53-
/* Per SERVER-22041, the count command in server versions before 3.3.2
54-
* may ignore the hint option if its query predicate is empty. */
55-
$filter = ['_id' => ['$exists' => true]];
56-
5751
foreach ($hintsUsingSparseIndex as $hint) {
58-
$operation = new Count($this->getDatabaseName(), $this->getCollectionName(), $filter, ['hint' => $hint]);
52+
$operation = new Count($this->getDatabaseName(), $this->getCollectionName(), [], ['hint' => $hint]);
5953
$this->assertSame(2, $operation->execute($this->getPrimaryServer()));
6054
}
6155

@@ -66,17 +60,13 @@ public function testHintOption(): void
6660
];
6761

6862
foreach ($hintsNotUsingSparseIndex as $hint) {
69-
$operation = new Count($this->getDatabaseName(), $this->getCollectionName(), $filter, ['hint' => $hint]);
63+
$operation = new Count($this->getDatabaseName(), $this->getCollectionName(), [], ['hint' => $hint]);
7064
$this->assertSame(3, $operation->execute($this->getPrimaryServer()));
7165
}
7266
}
7367

7468
public function testSessionOption(): void
7569
{
76-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
77-
$this->markTestSkipped('Sessions are not supported');
78-
}
79-
8070
(new CommandObserver())->observe(
8171
function (): void {
8272
$operation = new Count(

tests/Operation/CreateCollectionFunctionalTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use MongoDB\Operation\CreateCollection;
66
use MongoDB\Tests\CommandObserver;
77

8-
use function version_compare;
9-
108
class CreateCollectionFunctionalTest extends FunctionalTestCase
119
{
1210
public function testDefaultWriteConcernIsOmitted(): void
@@ -29,10 +27,6 @@ function (array $event): void {
2927

3028
public function testSessionOption(): void
3129
{
32-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
33-
$this->markTestSkipped('Sessions are not supported');
34-
}
35-
3630
(new CommandObserver())->observe(
3731
function (): void {
3832
$operation = new CreateCollection(

tests/Operation/CreateIndexesFunctionalTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ function (array $event): void {
153153

154154
public function testSessionOption(): void
155155
{
156-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
157-
$this->markTestSkipped('Sessions are not supported');
158-
}
159-
160156
(new CommandObserver())->observe(
161157
function (): void {
162158
$operation = new CreateIndexes(

tests/Operation/DatabaseCommandFunctionalTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
use MongoDB\Operation\DatabaseCommand;
66
use MongoDB\Tests\CommandObserver;
77

8-
use function version_compare;
9-
108
class DatabaseCommandFunctionalTest extends FunctionalTestCase
119
{
1210
public function testSessionOption(): void
1311
{
14-
if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
15-
$this->markTestSkipped('Sessions are not supported');
16-
}
17-
1812
(new CommandObserver())->observe(
1913
function (): void {
2014
$operation = new DatabaseCommand(

0 commit comments

Comments
 (0)