Repository navigation
PHPUnit: turns on PHP notices and deprecations - #43102
Merged
Merged
Conversation
10 of 11 tasks
hellofromtonya
force-pushed
the
fix/phpunit-notices-deprecations
branch
from
August 10, 2022 14:42
34a6cda to
cda782b
Compare
Contributor
Author
|
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.
hellofromtonya
force-pushed
the
fix/phpunit-notices-deprecations
branch
from
August 15, 2022 18:34
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.
6 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_Debugand 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.xmlconfiguration.Adds the following debug constants to the PHPUnit
bootstrap.phpfile: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.jsonfile?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.