fix: resolve global state pollution causing random-order test failures in HTTP suite#10372
Open
gr8man wants to merge 5 commits into
Open
fix: resolve global state pollution causing random-order test failures in HTTP suite#10372gr8man wants to merge 5 commits into
gr8man wants to merge 5 commits into
Conversation
Contributor
Author
|
IMPORTANT Note to reviewers and developers: Please ensure that tests are run regularly with the --order-by=random flag during development. Identifying test pollution and global state leakage bugs at a later stage is extremely difficult and time-consuming, as these failures only manifest under very specific test suite execution orders. |
1fcd77e to
dc8de21
Compare
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.
Description
This PR resolves multiple test pollution issues causing execution failures when tests in the HTTP system suite are executed in random order (
--order-by=random).Ref: #9968
Key Changes:
system/HTTP/IncomingRequest.php: Set the globally retrieved Negotiator service to non-shared (Services::negotiator($this, false)) to prevent cross-request negotiation state bleeding.tests/system/HTTP/UserAgentTest.php,tests/system/HTTP/NegotiateTest.php: Added class-level#[BackupGlobals(true)]and called$this->resetServices()insetUp()to restore mutated superglobals and clear mock services.tests/system/HTTP/RedirectResponseTest.php,tests/system/HTTP/ResponseTest.php,tests/system/HTTP/DownloadResponseTest.php: Added#[BackupGlobals(true)]to prevent superglobals mutation leakage.tests/system/HTTP/ResponseTest.php: Injected a clean, emptysuperglobalsmock insidetestSetLinkto isolate the URL generation from dirty query string pollution (e.g.code=good).tests/system/HTTP/IncomingRequestTest.php: Corrected unmatched close parenthesis typos in header strings and correctedtestNegotiatesLanguageassertion (changed expected output from'en'to'da') that was previously green only because of stale negotiator cache pollution.Checklist: