-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update PR 1751 + add tests, improve coverage. #3044
Update PR 1751 + add tests, improve coverage. #3044
Conversation
965a777
to
a6b384e
Compare
a6b384e
to
b1e8ac1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at the request of @costdev - note: this is only a partial review as I ran out of time, so I've reviewed only the first 662 lines of the test file.
$this->wp_filesystem_mock | ||
->expects( $this->exactly( 4 ) ) | ||
->method( 'is_writable' ) | ||
->withConsecutive( ...$unwritable_checks ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be aware that withConsecutive()
was deprecated in PHPUnit 9 and is being removed in PHPUnit 10.
Refs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that info! I'll have to see what's a suitable replacement for this then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: I'm yet to find a suitable replacement for this. From what I can see in the references above, an alternative hasn't been implemented, but I may be missing something. Not sure of the path to move this part forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrfnl As the WP test suite doesn't yet support PHPUnit 10 (via it's use of Yoast/PHPUnit-Polyfills 1.1), do you think it's worth putting this is as is to get some tests in for the class?
It doesn't look like there's a replacement for withConsecutive
yet but I see you did some work on PHPCSStandards/PHPCSUtils to manage that so let me know if you have other suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterwilsoncc For now, I'd just use the withConsecutive()
.
If/when we update the test suite for PHPUnit 10.x with Polyfills 2.x, we can implement a solution for all the places where withConsecutive()
is being used in one go. That should also make sure that we don't get fragmented solutions all over the place with people already trying to avoid withConsecutive()
, but there not being a replacement.
As a side-note: the reason for not updating the WP Core test suite for PHPUnit 10.x so far, is largely related to the changes in PHPUnit 10.x which make it neigh impossible to reliable check for PHP deprecations/notices/warnings in PHPUnit 10.x. That, combined with PHPUnit 9.x still running fine on PHP 8.3, means we don't have a reason at this time to update the test suite.
The PHP deprecations/notices/warnings change in PHPUnit 10.x means we won't be able to fail the test suite on those anymore (= problematic for WP) or if we turn the option on to fail the test suite, the tests suite would also fail on PHPUnit native warnings, which is something we really don't want.
On top of that we actually have tests setting expectations for PHP deprecations/notices/warning and those will also become problematic.
All in all, enough reason not to update (yet) if we don't have to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterwilsoncc For now, I'd just use the
withConsecutive()
.If/when we update the test suite for PHPUnit 10.x with Polyfills 2.x, we can implement a solution for all the places where
withConsecutive()
is being used in one go. That should also make sure that we don't get fragmented solutions all over the place with people already trying to avoidwithConsecutive()
, but there not being a replacement.
Thanks @jrfnl, I think I'll merge in trunk and commit what's in the PR to trunk and the 6.4 branch provided everything still passes, that will avoid what we have slipping another release.
b1e8ac1
to
57db617
Compare
Small code adjustments to have better type safety.
…e/Test standards.
57db617
to
77e8e3a
Compare
Tests added in r56992 / b5392cc and subsequently backported to the 6.4 branch. The |
This PR expands on PR 1754 to:
data_
prefixes for data providers per Trac 53119.$message
parameters per Core Handbook: Writing PHPUnit Tests - Using Assertions.static
where appropriate per Core Handbook: Writing PHPUnit Tests - One-off Functions for Hooks.tests/phpunit/includes/bootstrap.php
in PR 1754.Line coverage is now 48.21% with
trunk
.I believe this is as far as I can go for now with unit tests due to missing strings, a missing guard, and the use of general functions and the need to mock
WPDB
to ensure the tests are pure unit tests. Otherwise, integration tests can be added to cover the areas not covered by this PR.Trac ticket: https://core.trac.wordpress.org/ticket/54245