Skip to content

Commit aefbb46

Browse files
Merge v1.x into v2.x (#1443)
2 parents 823b074 + 0960e1c commit aefbb46

File tree

8 files changed

+26
-49
lines changed

8 files changed

+26
-49
lines changed

.evergreen/run-tests.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,30 @@ export MONGODB_MULTI_MONGOS_LB_URI="${MONGODB_MULTI_MONGOS_LB_URI}"
8383
# Run the tests, and store the results in a junit result file
8484
case "$TESTS" in
8585
atlas)
86-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group atlas
86+
php vendor/bin/phpunit $PHPUNIT_OPTS --group atlas
8787
;;
8888

8989
atlas-data-lake)
90-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group atlas-data-lake
90+
php vendor/bin/phpunit $PHPUNIT_OPTS --group atlas-data-lake
9191
;;
9292

9393
csfle)
94-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group csfle
94+
php vendor/bin/phpunit $PHPUNIT_OPTS --group csfle
9595
;;
9696

9797
csfle-without-aws-creds)
98-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group csfle-without-aws-creds
98+
php vendor/bin/phpunit $PHPUNIT_OPTS --group csfle-without-aws-creds
9999
;;
100100

101101
versioned-api)
102-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group versioned-api
102+
php vendor/bin/phpunit $PHPUNIT_OPTS --group versioned-api
103103
;;
104104

105105
serverless)
106-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS --group serverless
106+
php vendor/bin/phpunit $PHPUNIT_OPTS --group serverless
107107
;;
108108

109109
*)
110-
php vendor/bin/simple-phpunit $PHPUNIT_OPTS
110+
php vendor/bin/phpunit $PHPUNIT_OPTS
111111
;;
112112
esac

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
php-ini-values: "zend.assertions=1"
7878

7979
- name: "Run PHPUnit"
80-
run: "vendor/bin/simple-phpunit -v"
80+
run: "vendor/bin/phpunit -v"
8181
env:
8282
SYMFONY_DEPRECATIONS_HELPER: 999999
8383
MONGODB_URI: ${{ steps.setup-mongodb.outputs.cluster-uri }}

CONTRIBUTING.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ credentials in the connection string (i.e. `MONGODB_URI`) or set the
4343
Note that `MONGODB_USERNAME` and `MONGODB_PASSWORD` will override any
4444
credentials present in the connection string.
4545

46-
By default, the `simple-phpunit` binary chooses the correct PHPUnit version for
47-
the PHP version you are running. To run tests against a specific PHPUnit
48-
version, use the `SYMFONY_PHPUNIT_VERSION` environment variable:
49-
50-
```console
51-
$ SYMFONY_PHPUNIT_VERSION=8.5 vendor/bin/simple-phpunit
52-
```
53-
5446
### Environment Variables
5547

5648
The test suite references the following environment variables:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
},
2121
"require-dev": {
2222
"doctrine/coding-standard": "^12.0",
23+
"phpunit/phpunit": "^9.6",
2324
"rector/rector": "^1.1",
2425
"squizlabs/php_codesniffer": "^3.7",
25-
"symfony/phpunit-bridge": "^7.1",
2626
"vimeo/psalm": "^5.13"
2727
},
2828
"replace": {
@@ -50,7 +50,7 @@
5050
"fix:cs": "phpcbf",
5151
"fix:psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
5252
"fix:rector": "rector process --ansi",
53-
"test": "simple-phpunit"
53+
"test": "phpunit"
5454
},
5555
"extra": {
5656
"branch-alias": {

tests/GridFS/BucketFunctionalTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ public function testDanglingOpenWritableStream(): void
839839
}
840840

841841
$code = <<<'PHP'
842-
require '%s';
843842
require '%s';
844843
$client = MongoDB\Tests\FunctionalTestCase::createTestClient();
845844
$database = $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'phplib_test');
@@ -856,8 +855,6 @@ public function testDanglingOpenWritableStream(): void
856855
sprintf(
857856
$code,
858857
__DIR__ . '/../../vendor/autoload.php',
859-
// Include the PHPUnit autoload file to ensure PHPUnit classes can be loaded
860-
__DIR__ . '/../../vendor/bin/.phpunit/phpunit/vendor/autoload.php',
861858
),
862859
),
863860
'2>&1',
@@ -882,7 +879,6 @@ public function testDanglingOpenWritableStreamWithGlobalStreamWrapperAlias(): vo
882879
}
883880

884881
$code = <<<'PHP'
885-
require '%s';
886882
require '%s';
887883
$client = MongoDB\Tests\FunctionalTestCase::createTestClient();
888884
$database = $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'phplib_test');
@@ -899,8 +895,6 @@ public function testDanglingOpenWritableStreamWithGlobalStreamWrapperAlias(): vo
899895
sprintf(
900896
$code,
901897
__DIR__ . '/../../vendor/autoload.php',
902-
// Include the PHPUnit autoload file to ensure PHPUnit classes can be loaded
903-
__DIR__ . '/../../vendor/bin/.phpunit/phpunit/vendor/autoload.php',
904898
),
905899
),
906900
'2>&1',

tests/SpecTests/DocumentsMatchConstraint.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use SebastianBergmann\Comparator\ComparisonFailure;
1414
use SebastianBergmann\Comparator\Factory;
1515
use stdClass;
16-
use Symfony\Bridge\PhpUnit\ConstraintTrait;
1716

1817
use function array_values;
1918
use function get_debug_type;
@@ -36,8 +35,6 @@
3635
*/
3736
class DocumentsMatchConstraint extends Constraint
3837
{
39-
use ConstraintTrait;
40-
4138
/**
4239
* TODO: This is not currently used, but was preserved from the design of
4340
* TestCase::assertMatchesDocument(), which would sort keys and then compare
@@ -65,7 +62,7 @@ public function __construct(array|object $value, private bool $ignoreExtraKeysIn
6562
$this->comparatorFactory = Factory::getInstance();
6663
}
6764

68-
private function doEvaluate($other, $description = '', $returnResult = false)
65+
public function evaluate($other, string $description = '', bool $returnResult = false): ?bool
6966
{
7067
/* TODO: If ignoreExtraKeys and sortKeys are both false, then we may be
7168
* able to skip preparation, convert both documents to extended JSON,
@@ -100,6 +97,8 @@ private function doEvaluate($other, $description = '', $returnResult = false)
10097
if (! $success) {
10198
$this->fail($other, $description, $this->lastFailure);
10299
}
100+
101+
return null;
103102
}
104103

105104
/** @param string|BSONArray[] $expectedType */
@@ -198,7 +197,7 @@ private function assertEquals(ArrayObject $expected, ArrayObject $actual, bool $
198197
}
199198
}
200199

201-
private function doAdditionalFailureDescription($other)
200+
protected function additionalFailureDescription($other): string
202201
{
203202
if ($this->lastFailure === null) {
204203
return '';
@@ -207,12 +206,12 @@ private function doAdditionalFailureDescription($other)
207206
return $this->lastFailure->getMessage();
208207
}
209208

210-
private function doFailureDescription($other)
209+
protected function failureDescription($other): string
211210
{
212211
return 'two BSON objects are equal';
213212
}
214213

215-
private function doMatches($other)
214+
protected function matches($other): bool
216215
{
217216
/* TODO: If ignoreExtraKeys and sortKeys are both false, then we may be
218217
* able to skip preparation, convert both documents to extended JSON,
@@ -232,7 +231,7 @@ private function doMatches($other)
232231
return true;
233232
}
234233

235-
private function doToString()
234+
public function toString(): string
236235
{
237236
return 'matches ' . $this->exporter()->export($this->value);
238237
}

tests/UnifiedSpecTests/Constraint/IsBsonType.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use PHPUnit\Framework\Constraint\Constraint;
2424
use PHPUnit\Framework\Constraint\LogicalOr;
2525
use RuntimeException;
26-
use Symfony\Bridge\PhpUnit\ConstraintTrait;
2726

2827
use function array_keys;
2928
use function array_map;
@@ -40,8 +39,6 @@
4039

4140
final class IsBsonType extends Constraint
4241
{
43-
use ConstraintTrait;
44-
4542
private static array $types = [
4643
'double',
4744
'string',
@@ -88,7 +85,7 @@ public static function anyOf(string ...$types): Constraint
8885
return LogicalOr::fromConstraints(...array_map(fn ($type) => new self($type), $types));
8986
}
9087

91-
private function doMatches($other): bool
88+
protected function matches($other): bool
9289
{
9390
return match ($this->type) {
9491
'double' => is_float($other),
@@ -118,7 +115,7 @@ private function doMatches($other): bool
118115
};
119116
}
120117

121-
private function doToString(): string
118+
public function toString(): string
122119
{
123120
return sprintf('is of BSON type "%s"', $this->type);
124121
}

tests/UnifiedSpecTests/Constraint/Matches.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use RuntimeException;
1414
use SebastianBergmann\Comparator\ComparisonFailure;
1515
use SebastianBergmann\Comparator\Factory;
16-
use Symfony\Bridge\PhpUnit\ConstraintTrait;
1716

1817
use function array_keys;
1918
use function count;
@@ -49,8 +48,6 @@
4948
*/
5049
class Matches extends Constraint
5150
{
52-
use ConstraintTrait;
53-
5451
private mixed $value;
5552

5653
private bool $allowExtraRootKeys;
@@ -69,7 +66,7 @@ public function __construct($value, private ?EntityMap $entityMap = null, $allow
6966
$this->comparatorFactory = Factory::getInstance();
7067
}
7168

72-
private function doEvaluate($other, $description = '', $returnResult = false)
69+
public function evaluate($other, $description = '', $returnResult = false): ?bool
7370
{
7471
$other = self::prepare($other);
7572
$success = false;
@@ -104,6 +101,8 @@ private function doEvaluate($other, $description = '', $returnResult = false)
104101
if (! $success) {
105102
$this->fail($other, $description, $this->lastFailure);
106103
}
104+
105+
return null;
107106
}
108107

109108
private function assertEquals($expected, $actual, string $keyPath): void
@@ -321,8 +320,7 @@ private function assertMatchesOperator(BSONDocument $operator, $actual, string $
321320
throw new LogicException('unsupported operator: ' . $name);
322321
}
323322

324-
/** @see ConstraintTrait */
325-
private function doAdditionalFailureDescription($other)
323+
protected function additionalFailureDescription($other): string
326324
{
327325
if ($this->lastFailure === null) {
328326
return '';
@@ -331,14 +329,12 @@ private function doAdditionalFailureDescription($other)
331329
return $this->lastFailure->getMessage();
332330
}
333331

334-
/** @see ConstraintTrait */
335-
private function doFailureDescription($other)
332+
protected function failureDescription($other): string
336333
{
337334
return 'expected value matches actual value';
338335
}
339336

340-
/** @see ConstraintTrait */
341-
private function doMatches($other)
337+
protected function matches($other): bool
342338
{
343339
$other = self::prepare($other);
344340

@@ -351,8 +347,7 @@ private function doMatches($other)
351347
return true;
352348
}
353349

354-
/** @see ConstraintTrait */
355-
private function doToString()
350+
public function toString(): string
356351
{
357352
return 'matches ' . $this->exporter()->export($this->value);
358353
}

0 commit comments

Comments
 (0)