-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Refactor phpunit tests #36501
Refactor phpunit tests #36501
Conversation
7fe6672
to
8a8f9a2
Compare
Codecov Report
@@ Coverage Diff @@
## master #36501 +/- ##
============================================
+ Coverage 64.64% 64.66% +0.01%
Complexity 19049 19049
============================================
Files 1269 1269
Lines 74469 74497 +28
Branches 1311 1311
============================================
+ Hits 48142 48170 +28
Misses 25941 25941
Partials 386 386
Continue to review full report at Codecov.
|
8a8f9a2
to
91c914f
Compare
CI is failing because of fsweb.test.owncloud.com being down - see #36502 |
91c914f
to
0baa229
Compare
This is a weekend community contribution. |
0baa229
to
1135fa9
Compare
1135fa9
to
f0e2735
Compare
f0e2735
to
7ee6f4e
Compare
Thanks @individual-it - I got no response from anyone else. |
Description
Revive PR #34961 Declare testCase methods void to match modern phpunit declaration
And do stuff that we can do now in
phpunit7
and PHP 7.1 to be up-to-date forphpunit8
and PHP 7.2https://phpunit.de/announcements/phpunit-8.html
https://thephp.cc/news/2019/02/help-my-tests-stopped-working
PR #36499 runs
phpunit
tests withphpunit
V8. That is where we can see easily what stuff needs to be done to make thephpunit
tests more future-proof.the setup* and teardown* methods in
phpunit8
have return typevoid
, so they have to be declared like that where we inherit-override them.expectException
annotations are being deprecated in favour of$this->expectException()
so change them.https://thephp.cc/news/2016/02/questioning-phpunit-best-practices
php-cs-fixer fixes this automagically by adding this to the config:
That could be added to
owncloud-codestyle
so that we find and "fix" any of these in people's PRs.assertInternalType
is being deprecated in favour ofassertIsArray()
assertIsInt()
etc.Implement specialized alternatives to assertInternalType() and assertNotInternalType() sebastianbergmann/phpunit#3368
php-cs-fixer fixes this automagically by adding this to the config:
That could be added to
owncloud-codestyle
so that we find and "fix" any of these in people's PRs.there is now
assertStringContainsString
to replaceassertContains
when checking for a sub-string of a string. Use it.the
canonicalizing
parameter ofassertEquals
is being removed, so replace those usages withassertEqualsCanonicalizing
assertArraySubset
is being removed. Replace it with appropriate code. (We only used it in 2 places)In
tests/lib/Lock/LockingProvider.php
we now have calls toexpectException
. But some classes that inherit from this also have their ownexpectException
exception to expect. That is trouble for the test infrastructure to know which exception is really expected. Refactor that (see the diff of 7th commit)Similar for
tests/lib/Files/External/Service/StoragesServiceTest.php
- refactor for expected exception.Motivation and Context
Now that we are running
phpunit
V7, make the changes needed to be ready for V8...Then when we drop PHP 7.1 support in the future, we can also easily move to
phpunit
V8.How Has This Been Tested?
CI
Types of changes
Checklist: