Skip to content

Commit 61f4ecc

Browse files
Merge v1.x into v2.x (#1459)
2 parents 251bd4b + 7c1758c commit 61f4ecc

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

.evergreen/config/generate-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
// Test variants
5757
$allFiles[] = generateConfigs('buildvariants', 'test-variant', 'phpVersion', 'modern-php-full.yml', $supportedPhpVersions);
58-
// TODO: Re-enable when 1.20.0 is released
58+
// TODO: Re-enable when 2.0.0 is released
5959
// $allFiles[] = generateConfigs('buildvariants', 'test-variant', 'phpVersion', 'phpc.yml', [$latestPhpVersion]);
6060
// $allFiles[] = generateConfigs('buildvariants', 'test-variant', 'phpVersion', 'lowest.yml', [$lowestPhpVersion]);
6161

tests/Operation/FindFunctionalTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function () use ($modifiers): void {
4848
['modifiers' => $modifiers],
4949
);
5050

51-
$operation->execute($this->getPrimaryServer());
51+
$this->assertDeprecated(
52+
fn () => $operation->execute($this->getPrimaryServer()),
53+
);
5254
},
5355
function (array $event) use ($expectedSort): void {
5456
$this->assertEquals($expectedSort, $event['started']->getCommand()->sort ?? null);

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use function sprintf;
3838
use function strtr;
3939

40+
use const E_DEPRECATED;
4041
use const E_USER_DEPRECATED;
4142

4243
abstract class TestCase extends BaseTestCase
@@ -166,7 +167,7 @@ protected function assertDeprecated(callable $execution): void
166167

167168
set_error_handler(function ($errno, $errstr) use (&$errors): void {
168169
$errors[] = $errstr;
169-
}, E_USER_DEPRECATED);
170+
}, E_USER_DEPRECATED | E_DEPRECATED);
170171

171172
try {
172173
call_user_func($execution);

tests/UnifiedSpecTests/ExpectedError.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use MongoDB\Driver\Exception\ExecutionTimeoutException;
88
use MongoDB\Driver\Exception\RuntimeException;
99
use MongoDB\Driver\Exception\ServerException;
10-
use MongoDB\Driver\Exception\WriteException;
1110
use MongoDB\Tests\UnifiedSpecTests\Constraint\Matches;
1211
use PHPUnit\Framework\Assert;
1312
use stdClass;
@@ -157,14 +156,14 @@ public function assert(?Throwable $e = null): void
157156
}
158157

159158
if (isset($this->matchesResultDocument)) {
160-
assertThat($e, logicalOr(isInstanceOf(CommandException::class), isInstanceOf(WriteException::class)));
159+
assertThat($e, logicalOr(isInstanceOf(CommandException::class), isInstanceOf(BulkWriteException::class)));
161160

162161
if ($e instanceof CommandException) {
163162
assertThat($e->getResultDocument(), $this->matchesResultDocument, 'CommandException result document matches');
164-
} elseif ($e instanceof WriteException) {
163+
} elseif ($e instanceof BulkWriteException) {
165164
$writeErrors = $e->getWriteResult()->getErrorReplies();
166165
assertCount(1, $writeErrors);
167-
assertThat($writeErrors[0], $this->matchesResultDocument, 'WriteException result document matches');
166+
assertThat($writeErrors[0], $this->matchesResultDocument, 'BulkWriteException result document matches');
168167
}
169168
}
170169

tests/UnifiedSpecTests/ManagesFailPointsTrait.php

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

33
namespace MongoDB\Tests\UnifiedSpecTests;
44

5+
use MongoDB\Driver\Exception\ConnectionException;
56
use MongoDB\Driver\Server;
67
use MongoDB\Operation\DatabaseCommand;
78
use stdClass;
@@ -31,8 +32,14 @@ public function configureFailPoint(stdClass $failPoint, Server $server): void
3132
public function disableFailPoints(): void
3233
{
3334
foreach ($this->failPointsAndServers as [$failPoint, $server]) {
34-
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
35-
$operation->execute($server);
35+
try {
36+
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
37+
$operation->execute($server);
38+
} catch (ConnectionException) {
39+
// Retry once in case the connection was dropped by the last operation
40+
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
41+
$operation->execute($server);
42+
}
3643
}
3744

3845
$this->failPointsAndServers = [];

0 commit comments

Comments
 (0)