Closed
Conversation
Contributor
|
@sol-loup has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
mradmeta
approved these changes
Mar 5, 2025
mradmeta
approved these changes
Mar 5, 2025
Contributor
1 task
facebook-github-bot
pushed a commit
that referenced
this pull request
Mar 7, 2025
Summary: # Add Unit Tests for AsyncRequest Class Adds comprehensive unit tests for the AsyncRequest utility class. The tests verify: - Proper initialization of the class with correct action hooks - Request data handling via set_data() - Dispatch functionality with appropriate URL and arguments - Nonce verification in the request handling flow The implementation uses PHPUnit's mocking capabilities to intercept WordPress HTTP requests, as it's less straightforward / efficient to record and playback real network calls. I've verified that the changes originally pushed in #2901 and reverted in #2921 cause these tests to fail. Closes # . _Replace this with a good description of your changes & reasoning._ - [ ] Do the changed files pass `phpcs` checks? Please remove `phpcs:ignore` comments in changed files and fix any issues, or delete if not practical. ### Screenshots: ### Detailed test instructions: 1. 2. 3. ### Additional details: <!-- Optional. Enter a summary of all changes in this Pull Request, which will be added to the changelog if accepted. Each line should start with change type prefix`(Fix|Add|…) - `, for example: > Break - A change breaking previous API or functionality. > Add - A new feature, function or functionality was added. > Update - Big changes to something that wasn't broken. > Fix - Took care of something that wasn't working. > Tweak - Small change, that isn't actually very important. > Dev - Developer-facing only change. > Doc - Updated customer or developer facing documentation If you remove the "Changelog entry" header, the Pull Request title will be used as the changelog entry. Add the `changelog: none` label if no changelog entry is needed. --> ### Changelog entry > Pull Request resolved: #2922 Test Plan: Imported from GitHub, without a `Test Plan:` line. **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/17451448627576264 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/1125900312114451 Reviewed By: carterbuce, jczhuoMeta Differential Revision: D70733339 Pulled By: sol-loup fbshipit-source-id: 2fc7f837913cbe021ffa143021900076d80ee030
tzahgr
pushed a commit
that referenced
this pull request
Mar 25, 2025
Summary: # PR Summary This PR reverts the addition of explicit property declarations in the AsyncRequest class. We were seeing lint failures due to accessing an undefined property on the class. The original code relied on property_exists() checks to determine if child classes had defined custom properties for query arguments, URL, and request arguments. To fix the lint complaints, these variables were set to "null | undefined" on the class to indicate they were present but unused unless overridden dynamically. However, explicitly declaring these properties in the parent class, broke this logic since property_exists() now always returns true for these properties, even when they're null. This change restores the original dynamic property behavior, allowing child classes to optionally define these properties while maintaining the parent class's fallback logic. ### Screenshots: ### Detailed test instructions: 1. 2. 3. ### Additional details: <!-- Optional. Enter a summary of all changes in this Pull Request, which will be added to the changelog if accepted. Each line should start with change type prefix`(Fix|Add|…) - `, for example: > Break - A change breaking previous API or functionality. > Add - A new feature, function or functionality was added. > Update - Big changes to something that wasn't broken. > Fix - Took care of something that wasn't working. > Tweak - Small change, that isn't actually very important. > Dev - Developer-facing only change. > Doc - Updated customer or developer facing documentation If you remove the "Changelog entry" header, the Pull Request title will be used as the changelog entry. Add the `changelog: none` label if no changelog entry is needed. --> ### Changelog entry > Pull Request resolved: #2921 Test Plan: Imported from GitHub, without a `Test Plan:` line. **!---- (auto-generated) DO NOT EDIT OR PUT ANYTHING AFTER THIS LINE ----!** MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: bloks / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/281475381994203 MFTRunTestsScript Run / Test Suite: sa_checkout / Test Collection: www / Diff Version V1 https://internalfb.com/intern/testinfra/testrun/15762598767124196 Reviewed By: mradmeta Differential Revision: D70652138 Pulled By: sol-loup fbshipit-source-id: 396fadbca8106fbf88cfe1e2764f0cc05dfd7c49
Merged
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.
PR Summary
This PR reverts the addition of explicit property declarations in the AsyncRequest class.
We were seeing lint failures due to accessing an undefined property on the class.
The original code relied on property_exists() checks to determine if child classes had defined custom properties for query arguments, URL, and request arguments.
To fix the lint complaints, these variables were set to "null | undefined" on the class to indicate they were present but unused unless overridden dynamically.
However, explicitly declaring these properties in the parent class, broke this logic since property_exists() now always returns true for these properties, even when they're null.
This change restores the original dynamic property behavior, allowing child classes to optionally define these properties while maintaining the parent class's fallback logic.
Screenshots:
Detailed test instructions:
Additional details:
Changelog entry