Skip to content

Commit 3392d2b

Browse files
committed
Rename skipIfServerVersion & remove isPostBatchResumeTokenSupported
1 parent a49c4c8 commit 3392d2b

16 files changed

+40
-46
lines changed

tests/Collection/CrudSpecFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public function setUp(): void
5353
public function testSpecification(array $initialData, array $test, $minServerVersion, $maxServerVersion, $serverless): void
5454
{
5555
if (isset($minServerVersion)) {
56-
$this->skipIfServerVersionNotSupported('<', $minServerVersion);
56+
$this->skipIfServerVersion('<', $minServerVersion);
5757
}
5858

5959
if (isset($maxServerVersion)) {
60-
$this->skipIfServerVersionNotSupported('>=', $maxServerVersion);
60+
$this->skipIfServerVersion('>=', $maxServerVersion);
6161
}
6262

6363
$this->checkServerlessRequirement($serverless);

tests/DocumentationExamplesTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ public function testCausalConsistency(): void
15481548

15491549
public function testSnapshotQueries(): void
15501550
{
1551-
$this->skipIfServerVersionNotSupported('<', '5.0.0', 'Snapshot queries outside of transactions are not supported');
1551+
$this->skipIfServerVersion('<', '5.0.0', 'Snapshot queries outside of transactions are not supported');
15521552

15531553
if (! ($this->isReplicaSet() || $this->isShardedClusterUsingReplicasets())) {
15541554
$this->markTestSkipped('Snapshot read concern is only supported with replicasets');
@@ -1679,8 +1679,8 @@ public function testVersionedApi(): void
16791679

16801680
public function testVersionedApiMigration(): void
16811681
{
1682-
$this->skipIfServerVersionNotSupported('<', '5.0.0', 'Versioned API is not supported');
1683-
$this->skipIfServerVersionNotSupported('>=', '5.0.9', 'The count command was added to API version 1 (SERVER-63850)');
1682+
$this->skipIfServerVersion('<', '5.0.0', 'Versioned API is not supported');
1683+
$this->skipIfServerVersion('>=', '5.0.9', 'The count command was added to API version 1 (SERVER-63850)');
16841684

16851685
$this->dropCollection($this->getDatabaseName(), 'sales');
16861686
$uriString = static::getUri(true);
@@ -1809,7 +1809,7 @@ public function testQueryableEncryption(): void
18091809
$this->markTestSkipped('Queryable encryption requires replica sets');
18101810
}
18111811

1812-
$this->skipIfServerVersionNotSupported('<', '7.0.0', 'Explicit encryption tests require MongoDB 7.0 or later');
1812+
$this->skipIfServerVersion('<', '7.0.0', 'Explicit encryption tests require MongoDB 7.0 or later');
18131813

18141814
if (! $this->isEnterprise()) {
18151815
$this->markTestSkipped('Automatic encryption requires MongoDB Enterprise');

tests/FunctionalTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ protected function isShardedClusterUsingReplicasets()
484484
return preg_match('@^.*/.*:\d+@', $document['host']);
485485
}
486486

487-
protected function skipIfServerVersionNotSupported(string $operator, string $version, ?string $message = null): void
487+
protected function skipIfServerVersion(string $operator, string $version, ?string $message = null): void
488488
{
489489
if (version_compare($this->getServerVersion(), $version, $operator)) {
490490
$this->markTestSkipped($message ?? sprintf('Supported server version is %s %s', $operator, $version));

tests/Operation/BulkWriteFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function (array $event) use ($expectedReplacement): void {
200200
public function testUpdateDocuments($update, $expectedUpdate): void
201201
{
202202
if (is_array($expectedUpdate)) {
203-
$this->skipIfServerVersionNotSupported('<', '4.2.0', 'Pipeline-style updates are not supported');
203+
$this->skipIfServerVersion('<', '4.2.0', 'Pipeline-style updates are not supported');
204204
}
205205

206206
(new CommandObserver())->observe(
@@ -424,7 +424,7 @@ function (array $event): void {
424424

425425
public function testBulkWriteWithPipelineUpdates(): void
426426
{
427-
$this->skipIfServerVersionNotSupported('<', '4.2.0', 'Pipeline-style updates are not supported');
427+
$this->skipIfServerVersion('<', '4.2.0', 'Pipeline-style updates are not supported');
428428

429429
$this->createFixtures(4);
430430

tests/Operation/CreateEncryptedCollectionFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function setUp(): void
4141
$this->markTestSkipped('Queryable Encryption requires replica sets');
4242
}
4343

44-
$this->skipIfServerVersionNotSupported('<', '6.0.0', 'Queryable Encryption requires MongoDB 6.0 or later');
44+
$this->skipIfServerVersion('<', '6.0.0', 'Queryable Encryption requires MongoDB 6.0 or later');
4545

4646
$client = static::createTestClient();
4747

tests/Operation/CreateIndexesFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function (array $event): void {
188188

189189
public function testCommitQuorumOption(): void
190190
{
191-
$this->skipIfServerVersionNotSupported('<', '4.3.4', 'commitQuorum is not supported');
191+
$this->skipIfServerVersion('<', '4.3.4', 'commitQuorum is not supported');
192192

193193
if ($this->getPrimaryServer()->getType() !== Server::TYPE_RS_PRIMARY) {
194194
$this->markTestSkipped('commitQuorum is only supported on replica sets');
@@ -213,7 +213,7 @@ function (array $event): void {
213213

214214
public function testCommitQuorumUnsupported(): void
215215
{
216-
$this->skipIfServerVersionNotSupported('>=', '4.3.4', 'commitQuorum is supported');
216+
$this->skipIfServerVersion('>=', '4.3.4', 'commitQuorum is supported');
217217

218218
$operation = new CreateIndexes(
219219
$this->getDatabaseName(),

tests/Operation/DeleteFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testDeleteMany(): void
8585

8686
public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSideError(): void
8787
{
88-
$this->skipIfServerVersionNotSupported('>=', '4.4.0', 'hint is supported');
88+
$this->skipIfServerVersion('>=', '4.4.0', 'hint is supported');
8989

9090
$operation = new Delete(
9191
$this->getDatabaseName(),

tests/Operation/ExplainFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public function testUpdateOne($verbosity, $executionStatsExpected, $allPlansExec
327327

328328
public function testAggregate(): void
329329
{
330-
$this->skipIfServerVersionNotSupported('<', '4.0.0', 'Explaining aggregate command requires server version >= 4.0');
330+
$this->skipIfServerVersion('<', '4.0.0', 'Explaining aggregate command requires server version >= 4.0');
331331

332332
$this->createFixtures(3);
333333

@@ -344,7 +344,7 @@ public function testAggregate(): void
344344
/** @dataProvider provideVerbosityInformation */
345345
public function testAggregateOptimizedToQuery($verbosity, $executionStatsExpected, $allPlansExecutionExpected): void
346346
{
347-
$this->skipIfServerVersionNotSupported('<', '4.2.0', 'MongoDB < 4.2 does not optimize simple aggregation pipelines');
347+
$this->skipIfServerVersion('<', '4.2.0', 'MongoDB < 4.2 does not optimize simple aggregation pipelines');
348348

349349
$this->createFixtures(3);
350350

tests/Operation/FindAndModifyFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function (array $event): void {
127127

128128
public function testHintOptionUnsupportedClientSideError(): void
129129
{
130-
$this->skipIfServerVersionNotSupported('>=', '4.2.0', 'server reports error for unsupported findAndModify options');
130+
$this->skipIfServerVersion('>=', '4.2.0', 'server reports error for unsupported findAndModify options');
131131

132132
$operation = new FindAndModify(
133133
$this->getDatabaseName(),
@@ -143,7 +143,7 @@ public function testHintOptionUnsupportedClientSideError(): void
143143

144144
public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSideError(): void
145145
{
146-
$this->skipIfServerVersionNotSupported('>=', '4.4.0', 'hint is supported');
146+
$this->skipIfServerVersion('>=', '4.4.0', 'hint is supported');
147147

148148
$operation = new FindAndModify(
149149
$this->getDatabaseName(),

tests/Operation/MapReduceFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testResult(): void
107107

108108
public function testResultIncludesTimingWithVerboseOption(): void
109109
{
110-
$this->skipIfServerVersionNotSupported('>=', '4.3.0', 'mapReduce statistics are no longer exposed');
110+
$this->skipIfServerVersion('>=', '4.3.0', 'mapReduce statistics are no longer exposed');
111111

112112
$this->createFixtures(3);
113113

@@ -126,7 +126,7 @@ public function testResultIncludesTimingWithVerboseOption(): void
126126

127127
public function testResultDoesNotIncludeTimingWithoutVerboseOption(): void
128128
{
129-
$this->skipIfServerVersionNotSupported('>=', '4.3.0', 'mapReduce statistics are no longer exposed');
129+
$this->skipIfServerVersion('>=', '4.3.0', 'mapReduce statistics are no longer exposed');
130130

131131
$this->createFixtures(3);
132132

tests/Operation/UpdateFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function (array $event) use ($expectedFilter): void {
5656
public function testUpdateDocuments($update, $expectedUpdate): void
5757
{
5858
if (is_array($expectedUpdate)) {
59-
$this->skipIfServerVersionNotSupported('<', '4.2.0', 'Pipeline-style updates are not supported');
59+
$this->skipIfServerVersion('<', '4.2.0', 'Pipeline-style updates are not supported');
6060
}
6161

6262
(new CommandObserver())->observe(
@@ -151,7 +151,7 @@ function (array $event): void {
151151

152152
public function testHintOptionAndUnacknowledgedWriteConcernUnsupportedClientSideError(): void
153153
{
154-
$this->skipIfServerVersionNotSupported('>=', '4.2.0', 'hint is supported');
154+
$this->skipIfServerVersion('>=', '4.2.0', 'hint is supported');
155155

156156
$operation = new Update(
157157
$this->getDatabaseName(),

tests/Operation/WatchFunctionalTest.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function setUp(): void
6060
*/
6161
public function testGetResumeToken(): void
6262
{
63-
$this->skipIfPostBatchResumeTokenNotSupported();
63+
$this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken is supported');
6464

6565
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
6666
$changeStream = $operation->execute($this->getPrimaryServer());
@@ -105,7 +105,7 @@ public function testGetResumeToken(): void
105105
*/
106106
public function testGetResumeTokenWithPostBatchResumeToken(): void
107107
{
108-
$this->markTestSkipped('postBatchResumeToken is not supported');
108+
$this->skipIfServerVersion('<', '4.0.7', 'postBatchResumeToken is not supported');
109109

110110
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
111111

@@ -201,7 +201,7 @@ function (array $event) use (&$commands): void {
201201

202202
public function testResumeBeforeReceivingAnyResultsIncludesPostBatchResumeToken(): void
203203
{
204-
$this->markTestSkipped('postBatchResumeToken is not supported');
204+
$this->skipIfServerVersion('<', '4.0.7', 'postBatchResumeToken is not supported');
205205

206206
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
207207

@@ -275,8 +275,7 @@ public function testResumeBeforeReceivingAnyResultsIncludesStartAtOperationTime(
275275
$this->markTestSkipped('startAtOperationTime is not supported');
276276
}
277277

278-
// postBatchResumeToken takes precedence over startAtOperationTime
279-
$this->skipIfPostBatchResumeTokenNotSupported();
278+
$this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken takes precedence over startAtOperationTime');
280279

281280
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
282281

@@ -691,7 +690,7 @@ public function testInitialCursorIsNotClosed(): void
691690
*/
692691
public function testResumeTokenNotFoundClientSideError(): void
693692
{
694-
$this->skipIfServerVersionNotSupported('>=', '4.1.8', 'Server rejects change streams that modify resume token (SERVER-37786)');
693+
$this->skipIfServerVersion('>=', '4.1.8', 'Server rejects change streams that modify resume token (SERVER-37786)');
695694

696695
$pipeline = [['$project' => ['_id' => 0]]];
697696

@@ -717,7 +716,7 @@ public function testResumeTokenNotFoundClientSideError(): void
717716
*/
718717
public function testResumeTokenNotFoundServerSideError(): void
719718
{
720-
$this->skipIfServerVersionNotSupported('<', '4.1.8', 'Server does not reject change streams that modify resume token');
719+
$this->skipIfServerVersion('<', '4.1.8', 'Server does not reject change streams that modify resume token');
721720

722721
$pipeline = [['$project' => ['_id' => 0]]];
723722

@@ -738,7 +737,7 @@ public function testResumeTokenNotFoundServerSideError(): void
738737
*/
739738
public function testResumeTokenInvalidTypeClientSideError(): void
740739
{
741-
$this->skipIfServerVersionNotSupported('>=', '4.1.8', 'Server rejects change streams that modify resume token (SERVER-37786)');
740+
$this->skipIfServerVersion('>=', '4.1.8', 'Server rejects change streams that modify resume token (SERVER-37786)');
742741

743742
$pipeline = [['$project' => ['_id' => ['$literal' => 'foo']]]];
744743

@@ -764,7 +763,7 @@ public function testResumeTokenInvalidTypeClientSideError(): void
764763
*/
765764
public function testResumeTokenInvalidTypeServerSideError(): void
766765
{
767-
$this->skipIfServerVersionNotSupported('<', '4.1.8', 'Server does not reject change streams that modify resume token');
766+
$this->skipIfServerVersion('<', '4.1.8', 'Server does not reject change streams that modify resume token');
768767

769768
$pipeline = [['$project' => ['_id' => ['$literal' => 'foo']]]];
770769

@@ -948,7 +947,7 @@ public function testResumeAfterOption(): void
948947

949948
public function testStartAfterOption(): void
950949
{
951-
$this->skipIfServerVersionNotSupported('<', '4.1.1', 'startAfter is not supported');
950+
$this->skipIfServerVersion('<', '4.1.1', 'startAfter is not supported');
952951

953952
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
954953
$changeStream = $operation->execute($this->getPrimaryServer());
@@ -1158,7 +1157,7 @@ function (array $event) use (&$sessionAfterResume, &$commands): void {
11581157
public function testSessionFreed(): void
11591158
{
11601159
if ($this->isShardedCluster()) {
1161-
$this->skipIfServerVersionNotSupported('>=', '5.1.0', 'mongos still reports non-zero cursor ID for invalidated change stream (SERVER-60764)');
1160+
$this->skipIfServerVersion('>=', '5.1.0', 'mongos still reports non-zero cursor ID for invalidated change stream (SERVER-60764)');
11621161
}
11631162

11641163
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
@@ -1265,7 +1264,7 @@ function (array $aggregateCommand) {
12651264
*/
12661265
public function testErrorDuringAggregateCommandDoesNotCauseResume(): void
12671266
{
1268-
$this->skipIfServerVersionNotSupported('<', '4.0.0', 'failCommand is not supported');
1267+
$this->skipIfServerVersion('<', '4.0.0', 'failCommand is not supported');
12691268

12701269
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
12711270

@@ -1342,7 +1341,7 @@ function () {
13421341
*/
13431342
public function testGetResumeTokenReturnsOriginalResumeTokenOnEmptyBatch(): void
13441343
{
1345-
$this->skipIfPostBatchResumeTokenNotSupported();
1344+
$this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken is supported');
13461345

13471346
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
13481347
$changeStream = $operation->execute($this->getPrimaryServer());
@@ -1376,7 +1375,7 @@ public function testGetResumeTokenReturnsOriginalResumeTokenOnEmptyBatch(): void
13761375
*/
13771376
public function testResumeTokenBehaviour(): void
13781377
{
1379-
$this->skipIfServerVersionNotSupported('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
1378+
$this->skipIfServerVersion('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
13801379
$this->skipIfIsShardedCluster('Resume token behaviour can\'t be reliably tested on sharded clusters.');
13811380

13821381
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
@@ -1432,7 +1431,7 @@ public function testResumeTokenBehaviour(): void
14321431
*/
14331432
public function testResumingChangeStreamWithoutPreviousResultsIncludesStartAfterOption(): void
14341433
{
1435-
$this->skipIfServerVersionNotSupported('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
1434+
$this->skipIfServerVersion('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
14361435

14371436
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
14381437
$changeStream = $operation->execute($this->getPrimaryServer());
@@ -1477,7 +1476,7 @@ function (array $event) use (&$aggregateCommand): void {
14771476
*/
14781477
public function testResumingChangeStreamWithPreviousResultsIncludesResumeAfterOption(): void
14791478
{
1480-
$this->skipIfServerVersionNotSupported('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
1479+
$this->skipIfServerVersion('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
14811480

14821481
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
14831482
$changeStream = $operation->execute($this->getPrimaryServer());
@@ -1567,11 +1566,6 @@ private function insertDocument($document): void
15671566
$this->assertEquals(1, $writeResult->getInsertedCount());
15681567
}
15691568

1570-
private function skipIfPostBatchResumeTokenNotSupported(): void
1571-
{
1572-
$this->skipIfServerVersionNotSupported('>=', '4.0.7', 'postBatchResumeToken is supported');
1573-
}
1574-
15751569
private function isStartAtOperationTimeSupported()
15761570
{
15771571
return server_supports_feature($this->getPrimaryServer(), self::$wireVersionForStartAtOperationTime);

tests/SpecTests/ClientSideEncryption/Prose21_AutomaticDataEncryptionKeysTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function setUp(): void
3434
$this->markTestSkipped('Automatic data encryption key tests require replica sets');
3535
}
3636

37-
$this->skipIfServerVersionNotSupported('<', '7.0.0', 'Automatic data encryption key tests require MongoDB 7.0 or later');
37+
$this->skipIfServerVersion('<', '7.0.0', 'Automatic data encryption key tests require MongoDB 7.0 or later');
3838

3939
$client = static::createTestClient();
4040
$this->database = $client->selectDatabase($this->getDatabaseName());

tests/SpecTests/ClientSideEncryption/Prose22_RangeExplicitEncryptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function setUp(): void
4040
$this->markTestSkipped('Range explicit encryption tests require replica sets');
4141
}
4242

43-
$this->skipIfServerVersionNotSupported('<', '7.0.0', 'Range explicit encryption tests require MongoDB 7.0 or later');
43+
$this->skipIfServerVersion('<', '7.0.0', 'Range explicit encryption tests require MongoDB 7.0 or later');
4444

4545
$client = static::createTestClient();
4646

tests/SpecTests/ClientSideEncryptionSpecTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ public function testExplicitEncryption(Closure $test): void
13381338
$this->markTestSkipped('Explicit encryption tests require replica sets');
13391339
}
13401340

1341-
$this->skipIfServerVersionNotSupported('<', '7.0.0', 'Explicit encryption tests require MongoDB 7.0 or later');
1341+
$this->skipIfServerVersion('<', '7.0.0', 'Explicit encryption tests require MongoDB 7.0 or later');
13421342

13431343
// Test setup
13441344
$encryptedFields = $this->decodeJson(file_get_contents(__DIR__ . '/client-side-encryption/etc/data/encryptedFields.json'));

tests/SpecTests/RetryableWritesSpecTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testNoWritesPerformedErrorReturnsOriginalError(): void
8989
$this->markTestSkipped('Test only applies to replica sets');
9090
}
9191

92-
$this->skipIfServerVersionNotSupported('<', '4.4.0', 'NoWritesPerformed error label is only supported on MongoDB 4.4+');
92+
$this->skipIfServerVersion('<', '4.4.0', 'NoWritesPerformed error label is only supported on MongoDB 4.4+');
9393

9494
$client = self::createTestClient(null, ['retryWrites' => true]);
9595

0 commit comments

Comments
 (0)