Prevent sending Location header during test_perflab_aea_clean_aea_audit_action#926
Conversation
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks @westonruter for the PR.
The test_ilo_get_normalized_query_vars and test_ilo_can_optimize_response tests change the global state for the URL so can we fixed those test instead of changing this test?
If we add $this->go_to( '' ); at bottom of both tests it will fixed the issue. Could you please take a look it. Thanks!
felixarntz
left a comment
There was a problem hiding this comment.
@westonruter This fix makes sense to me. With your changes, the test no longer relies on the global query vars / URL state, but forces a referer. Previously this didn't work correctly since the wp_get_referer() call returned false and thus remove_query_arg() would call the "current" URL.
Separately, I partially agree with @mukeshpanchal27's feedback that we should also ensure the go_to() calls in #898 don't pollute global state, which is potentially the reason this failure was triggered in your branch.
OK, I've fixed this in #898 by unsetting Nevertheless, as Felix notes, this change is still an improvement. |
Summary
In working on #898, I noticed PHPUnit failing with:
This is due to
wp_safe_redirect()being called byperflab_aea_clean_aea_audit_action()which is attempting to send theLocationheader during testing.It's not clear to me why this unit test failure is not occurring in
trunk.Relevant technical choices
Prevent
wp_safe_redirect()from sending theLocationheader via thewp_redirectfilter in the unit test. Capture the redirected URL and test that it is as expected.Checklist
[Focus]orInfrastructurelabel.[Type]label.no milestonelabel.