Skip to content

Commit 4974348

Browse files
authored
Merge pull request #791 from alcaeus/phpunit-bridge
PHPLIB-597: Replace direct PHPUnit dependency with symfony/phpunit-bridge
2 parents 4608a73 + 20236e1 commit 4974348

38 files changed

+592
-464
lines changed

.evergreen/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ functions:
162162
display_name: "drivers-dir.tar.gz"
163163

164164
"upload test results":
165-
- command: attach.results
165+
- command: attach.xunit_results
166166
params:
167-
file_location: "${PROJECT_DIRECTORY}/test-results.json"
167+
file: "${PROJECT_DIRECTORY}/test-results.xml"
168168
- command: attach.results
169169
params:
170170
file_location: "${DRIVERS_TOOLS}/results.json"

.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>

phpunit.evergreen.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
</testsuite>
2727
</testsuites>
2828

29-
<listeners>
30-
<listener class="MongoDB\Tests\EvergreenLogListener">
31-
<arguments>
32-
<string>test-results.json</string>
33-
</arguments>
34-
</listener>
35-
</listeners>
29+
<logging>
30+
<log type="junit" target="test-results.xml" />
31+
</logging>
3632
</phpunit>

tests/Compat/PolyfillAssertTrait.php

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

tests/EvergreenLogListener.php

Lines changed: 0 additions & 205 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

0 commit comments

Comments
 (0)