-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
PHPUnit: turns on PHP notices and deprecations #43102
Conversation
34a6cda
to
cda782b
Compare
UPDATED: 17 Aug 2022: This failing test has been fixed and merged into One PHPUnit is failing. Issue #43121 is opened for this issue and PR #43122 resolves the issue.
Once fixed, then this PR can be updated with recent |
* Setup `WP_Block_Supports::$block_to_render`. Fixes error: "Trying to access array offset on value of type null" as `WP_Block_Supports::$block_to_render` is `null` by default. * Separates invalid input datasets for testing the notice. * Adds `$this->expectNotice()` where expected.
cda782b
to
dd6c556
Compare
Deprecation notices are thrown in the e2e tests when setting debug on in the .wp-env.json file. Though these need resolution, adding assertions to expect the deprecations in the e2e tests is outside the scope of this PR.
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 Tonya! LGTM 🚢
Part of #43333
What?
expectNotice()
assertion when a notice is expected to happen.This PR brings closer parity to Core which also turns on debug constants such as
WP_Debug
and usesexpectNotice()
.Why?
Reasons:
PHP notices and deprecations provide helpful information for identifying issues and/or code changes.
For example:
Once backported, Core's tests will fail if there are deprecations or notices thrown, as its test suite turns on debug. By catching these here in Gutenberg's repo, it provides information for resolution before backporting to Core. Why is necessary? In many instances, source code needs changing including adding defensive guarding. Finding these issues during development allows time for investigation and consideration of design intent to properly remedy the issue.
How?
Adds
convertDeprecationsToExceptions="true"
tophp.xml
configuration.Adds the following debug constants to the PHPUnit
bootstrap.php
file:WP_Debug
,LOCAL_WP_DEBUG_LOG
,LOCAL_WP_DEBUG_DISPLAY
,LOCAL_SCRIPT_DEBUG
.Changes are in the test suite only. Issues within the source code need individual consideration for what the code should do before it attempts to run the code that triggers the notice or deprecation.
FAQ
.wp-env.json
file?This PR tried that and found that deprecation notices are being thrown in the e2e tests. This PR is focused on PHPUnit only. Adding deprecation expectations to the e2e tests is outside the scope of this PR.
Yes and no. Their site will continue running. But unexpected results may happen as the code does not have what it needs to process. The deprecations and notices are identifying where that a problem exists and needs attention.