Skip to content

Commit bdb8f98

Browse files
committed
PHPLIB-597: Remove explicit dependency on PHPUnit in favour of phpunit-bridge
1 parent 4608a73 commit bdb8f98

35 files changed

+587
-250
lines changed

.evergreen/run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ PATH=/opt/php/${PHP_VERSION}-64bit/bin:$OLD_PATH
2626
case "$TESTS" in
2727
atlas-data-lake*)
2828
MONGODB_URI="mongodb://mhuser:[email protected]:27017"
29-
php vendor/bin/phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite"
29+
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite"
3030
;;
3131

3232
*)
33-
php vendor/bin/phpunit --configuration phpunit.evergreen.xml
33+
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml
3434
;;
3535
esac

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ before_script:
165165
script:
166166
- export MONGODB_URI=`cat /tmp/uri.txt`
167167
- echo $MONGODB_URI
168-
- vendor/bin/phpunit -v
168+
- vendor/bin/simple-phpunit -v
169169

170170
before_cache:
171171
- rm -f ${HOME}/.cache/pip/log/debug.log

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ Installation directions for Composer may be found in its
2020

2121
## Testing
2222

23-
The library's test suite uses [PHPUnit](https://phpunit.de/), which should be
24-
installed as a development dependency by Composer.
23+
The library's test suite uses [PHPUnit](https://phpunit.de/), which is installed
24+
through the [PHPUnit Bridge](https://symfony.com/phpunit-bridge) dependency by
25+
Composer.
2526

2627
The test suite may be executed with:
2728

2829
```
29-
$ vendor/bin/phpunit
30+
$ vendor/bin/simple-phpunit
3031
```
3132

3233
The `phpunit.xml.dist` file is used as the default configuration file for the

composer.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
"jean85/pretty-package-versions": "^1.2"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^6.5",
20-
"sebastian/comparator": "^2.0 || ^3.0",
2119
"squizlabs/php_codesniffer": "^3.5, <3.5.5",
22-
"symfony/phpunit-bridge": "^4.4@dev"
20+
"symfony/phpunit-bridge": "^5.2@beta"
2321
},
2422
"autoload": {
2523
"psr-4": { "MongoDB\\": "src/" },
@@ -29,11 +27,19 @@
2927
"psr-4": { "MongoDB\\Tests\\": "tests/" },
3028
"// Manually include assertion functions for PHPUnit 8.x and earlier ":"",
3129
"// See: https://github.com/sebastianbergmann/phpunit/issues/3746 ":"",
32-
"files": [ "vendor/phpunit/phpunit/src/Framework/Assert/Functions.php" ]
30+
"files": [
31+
"vendor/bin/.phpunit/phpunit/src/Framework/Assert/Functions.php",
32+
"tests/PHPUnit/FunctionsPolyfill.php"
33+
]
3334
},
3435
"extra": {
3536
"branch-alias": {
3637
"dev-master": "1.8.x-dev"
3738
}
39+
},
40+
"scripts": {
41+
"// Ensure PHPUnit is installed through the PHPUnit bridge before ":"",
42+
"// dumping the autoloader to avoid errors due to missing files.":"",
43+
"pre-autoload-dump": "if test -f vendor/bin/simple-phpunit; then vendor/bin/simple-phpunit --version > /dev/null; fi"
3844
}
3945
}

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@
113113
</rule>
114114

115115
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
116-
<exclude-pattern>/tests/Compat/PolyfillAssertTrait.php</exclude-pattern>
116+
<exclude-pattern>/tests/PHPUnit/ConstraintTrait.php</exclude-pattern>
117117
</rule>
118118
</ruleset>

tests/Compat/PolyfillAssertTrait.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/GridFS/BucketFunctionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public function testDownloadToStreamFails()
721721
$this->bucket->uploadFromStream('filename', $this->createStream('foo'), ['_id' => ['foo' => 'bar']]);
722722

723723
$this->expectException(StreamException::class);
724-
$this->expectExceptionMessageRegExp('#^Downloading file from "gridfs://.*/.*/.*" to "php://temp" failed. GridFS identifier: "{ "_id" : { "foo" : "bar" } }"$#');
724+
$this->expectExceptionMessageMatches('#^Downloading file from "gridfs://.*/.*/.*" to "php://temp" failed. GridFS identifier: "{ "_id" : { "foo" : "bar" } }"$#');
725725
$this->bucket->downloadToStream(['foo' => 'bar'], fopen('php://temp', 'r'));
726726
}
727727

@@ -730,7 +730,7 @@ public function testDownloadToStreamByNameFails()
730730
$this->bucket->uploadFromStream('filename', $this->createStream('foo'));
731731

732732
$this->expectException(StreamException::class);
733-
$this->expectExceptionMessageRegExp('#^Downloading file from "gridfs://.*/.*/.*" to "php://temp" failed. GridFS filename: "filename"$#');
733+
$this->expectExceptionMessageMatches('#^Downloading file from "gridfs://.*/.*/.*" to "php://temp" failed. GridFS filename: "filename"$#');
734734
$this->bucket->downloadToStreamByName('filename', fopen('php://temp', 'r'));
735735
}
736736

@@ -744,7 +744,7 @@ public function testUploadFromStreamFails()
744744
$source = fopen('unusable://temp', 'w');
745745

746746
$this->expectException(StreamException::class);
747-
$this->expectExceptionMessageRegExp('#^Uploading file from "unusable://temp" to "gridfs://.*/.*/.*" failed. GridFS filename: "filename"$#');
747+
$this->expectExceptionMessageMatches('#^Uploading file from "unusable://temp" to "gridfs://.*/.*/.*" failed. GridFS filename: "filename"$#');
748748
$this->bucket->uploadFromStream('filename', $source);
749749
}
750750

tests/Operation/BulkWriteFunctionalTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function testUnacknowledgedWriteConcern()
171171
public function testUnacknowledgedWriteConcernAccessesDeletedCount(BulkWriteResult $result)
172172
{
173173
$this->expectException(BadMethodCallException::class);
174-
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
174+
$this->expectExceptionMessageMatches('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
175175
$result->getDeletedCount();
176176
}
177177

@@ -181,7 +181,7 @@ public function testUnacknowledgedWriteConcernAccessesDeletedCount(BulkWriteResu
181181
public function testUnacknowledgedWriteConcernAccessesInsertCount(BulkWriteResult $result)
182182
{
183183
$this->expectException(BadMethodCallException::class);
184-
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
184+
$this->expectExceptionMessageMatches('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
185185
$result->getInsertedCount();
186186
}
187187

@@ -191,7 +191,7 @@ public function testUnacknowledgedWriteConcernAccessesInsertCount(BulkWriteResul
191191
public function testUnacknowledgedWriteConcernAccessesMatchedCount(BulkWriteResult $result)
192192
{
193193
$this->expectException(BadMethodCallException::class);
194-
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
194+
$this->expectExceptionMessageMatches('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
195195
$result->getMatchedCount();
196196
}
197197

@@ -201,7 +201,7 @@ public function testUnacknowledgedWriteConcernAccessesMatchedCount(BulkWriteResu
201201
public function testUnacknowledgedWriteConcernAccessesModifiedCount(BulkWriteResult $result)
202202
{
203203
$this->expectException(BadMethodCallException::class);
204-
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
204+
$this->expectExceptionMessageMatches('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
205205
$result->getModifiedCount();
206206
}
207207

@@ -211,7 +211,7 @@ public function testUnacknowledgedWriteConcernAccessesModifiedCount(BulkWriteRes
211211
public function testUnacknowledgedWriteConcernAccessesUpsertedCount(BulkWriteResult $result)
212212
{
213213
$this->expectException(BadMethodCallException::class);
214-
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
214+
$this->expectExceptionMessageMatches('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
215215
$result->getUpsertedCount();
216216
}
217217

@@ -221,7 +221,7 @@ public function testUnacknowledgedWriteConcernAccessesUpsertedCount(BulkWriteRes
221221
public function testUnacknowledgedWriteConcernAccessesUpsertedIds(BulkWriteResult $result)
222222
{
223223
$this->expectException(BadMethodCallException::class);
224-
$this->expectExceptionMessageRegExp('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
224+
$this->expectExceptionMessageMatches('/[\w:\\\\]+ should not be called for an unacknowledged write result/');
225225
$result->getUpsertedIds();
226226
}
227227

0 commit comments

Comments
 (0)