Enter the test-case context before checking a test's requirements#6779
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 13.2 #6779 +/- ##
=========================================
Coverage 97.66% 97.66%
Complexity 8696 8696
=========================================
Files 868 868
Lines 26554 26554
=========================================
Hits 25933 25933
Misses 621 621 ☔ View full report in Codecov by Harness. |
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.
This fixes a regression introduced in 13.2.0.
When a deprecation is triggered while PHPUnit evaluates a test's requirements — for example, a
#[RequiresMethod]attribute whosemethod_exists()check autoloads a class that triggers a deprecation as a side effect of being loaded — the deprecation is reported as having been "triggered outside of tests". As a result it cannot be silenced with#[IgnoreDeprecations], it is not written to a generated baseline, and it makes the suite fail under--fail-on-deprecation. The same code did not report this deprecation in 13.1.The cause is in
TestBuilder::build():requirementsSatisfied()(which performs the requirement checks, and therefore the autoloading) is called beforeErrorHandler::enterTestCaseContext(). Since 13.2 has an error handler active for the non-test-case context during test building, a deprecation triggered there is emitted immediately as "outside of tests" instead of being deferred to the test it belongs to.This moves the
enterTestCaseContext()/leaveTestCaseContext()window so it also coversrequirementsSatisfied()andfilterExcludesMethod(). The deprecation is then deferred and replayed in the context of the test — exactly as already happens for deprecations triggered in data providers — so it is attributed to the test, honours#[IgnoreDeprecations], and is written to the baseline.A regression test (
tests/end-to-end/regression/6778) is included; it fails before this change ("triggered outside of tests") and passes after. The fullend-to-endtest suite remains green.Closes #6778