Skip to content

PHPLIB-597: Replace direct PHPUnit dependency with symfony/phpunit-bridge #791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ functions:
display_name: "drivers-dir.tar.gz"

"upload test results":
- command: attach.results
- command: attach.xunit_results
params:
file_location: "${PROJECT_DIRECTORY}/test-results.json"
file: "${PROJECT_DIRECTORY}/test-results.xml"
- command: attach.results
params:
file_location: "${DRIVERS_TOOLS}/results.json"
Expand Down
4 changes: 2 additions & 2 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ PATH=/opt/php/${PHP_VERSION}-64bit/bin:$OLD_PATH
case "$TESTS" in
atlas-data-lake*)
MONGODB_URI="mongodb://mhuser:[email protected]:27017"
php vendor/bin/phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite"
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml --testsuite "Atlas Data Lake Test Suite"
;;

*)
php vendor/bin/phpunit --configuration phpunit.evergreen.xml
php vendor/bin/simple-phpunit --configuration phpunit.evergreen.xml
;;
esac
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ before_script:
script:
- export MONGODB_URI=`cat /tmp/uri.txt`
- echo $MONGODB_URI
- vendor/bin/phpunit -v
- vendor/bin/simple-phpunit -v

before_cache:
- rm -f ${HOME}/.cache/pip/log/debug.log
Expand Down
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ Installation directions for Composer may be found in its

## Testing

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

The test suite may be executed with:

```
$ vendor/bin/phpunit
$ vendor/bin/simple-phpunit
```

The `phpunit.xml.dist` file is used as the default configuration file for the
Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"jean85/pretty-package-versions": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"sebastian/comparator": "^2.0 || ^3.0",
"squizlabs/php_codesniffer": "^3.5, <3.5.5",
"symfony/phpunit-bridge": "^4.4@dev"
"symfony/phpunit-bridge": "^5.2@beta"
},
"autoload": {
"psr-4": { "MongoDB\\": "src/" },
Expand All @@ -29,11 +27,19 @@
"psr-4": { "MongoDB\\Tests\\": "tests/" },
"// Manually include assertion functions for PHPUnit 8.x and earlier ":"",
"// See: https://github.com/sebastianbergmann/phpunit/issues/3746 ":"",
"files": [ "vendor/phpunit/phpunit/src/Framework/Assert/Functions.php" ]
"files": [
"vendor/bin/.phpunit/phpunit/src/Framework/Assert/Functions.php",
"tests/PHPUnit/FunctionsPolyfill.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
}
},
"scripts": {
"// Ensure PHPUnit is installed through the PHPUnit bridge before ":"",
"// dumping the autoloader to avoid errors due to missing files.":"",
"pre-autoload-dump": "if test -f vendor/bin/simple-phpunit; then vendor/bin/simple-phpunit --version > /dev/null; fi"
}
}
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>/tests/Compat/PolyfillAssertTrait.php</exclude-pattern>
<exclude-pattern>/tests/PHPUnit/ConstraintTrait.php</exclude-pattern>
</rule>
</ruleset>
10 changes: 3 additions & 7 deletions phpunit.evergreen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
</testsuite>
</testsuites>

<listeners>
<listener class="MongoDB\Tests\EvergreenLogListener">
<arguments>
<string>test-results.json</string>
</arguments>
</listener>
</listeners>
<logging>
<log type="junit" target="test-results.xml" />
</logging>
</phpunit>
25 changes: 0 additions & 25 deletions tests/Compat/PolyfillAssertTrait.php

This file was deleted.

205 changes: 0 additions & 205 deletions tests/EvergreenLogListener.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/GridFS/BucketFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public function testDownloadToStreamFails()
$this->bucket->uploadFromStream('filename', $this->createStream('foo'), ['_id' => ['foo' => 'bar']]);

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

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

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

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

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

Expand Down
Loading