[Tests-Only] Adjust unit tests for the future#37169
Conversation
Codecov Report
@@ Coverage Diff @@
## master #37169 +/- ##
=========================================
Coverage 64.87% 64.87%
Complexity 19146 19146
=========================================
Files 1269 1269
Lines 74947 74947
Branches 1331 1331
=========================================
Hits 48625 48625
Misses 25930 25930
Partials 392 392
Continue to review full report at Codecov.
|
|
I don't really like to have dummy interfaces to "join" different classes or interfaces even if it's just for tests. From my point of view, there is either a problem in the code or in the tests. |
I agree. Where I could, I found a class or interface that already implemented at least the multiple interfaces. It seemed odd to me that existing tests mock a combined set of interfaces, but there is nowhere in the actual codebase that seems to use exactly that combined set of interfaces. I didn't want to mess with actual "real" interface/class hierarchy because that would add potential for getting it wrong, and refactoring (redesigning?) a lot of that stuff seemed out-of-scope. Some related discussion that gave me the idea: https://stackoverflow.com/questions/8544171/phpunit-stubbing-multiple-interfaces |
633bd80 to
03366f3
Compare
jvillafanez
left a comment
There was a problem hiding this comment.
I'd write a fixme or todo comment for each of the dummy interfaces, mainly to ensure we'll know in the future that we didn't have a better choice.
|
ToDo comments have been added. |
Description
These are some changes that can be made now to PHP unit tests.
phpunit8 reports various deprecations. See example PR #37168Remove undeclared property PHPUnit\Framework\Error\Deprecated - not valid/needed any more with phpunit8 - we will also be fine removing this now for phpunit7, if people write new unit test code it will be useful to have the new unit test code fail if it uses things that have been deprecated,
Stop using assertAttributeEquals in tests/lib/ConfigTest.php - that assert is deprecated and being removed. I wrote a function that does an
assertEqualsfor each item.Adjust createMock calls to remove deprecated array of interface names -
createMock()can only be passed a single class/interface. phpunit8 reports:How Has This Been Tested?
CI
Types of changes
Checklist: