Skip to content

Add Unit Tests for AsyncRequest Class#2922

Closed
sol-loup wants to merge 4 commits intomainfrom
test-coverage-03-05-25
Closed

Add Unit Tests for AsyncRequest Class#2922
sol-loup wants to merge 4 commits intomainfrom
test-coverage-03-05-25

Conversation

@sol-loup
Copy link
Copy Markdown
Contributor

@sol-loup sol-loup commented Mar 5, 2025

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:

Additional details:

Changelog entry

Copy link
Copy Markdown
Contributor

@jczhuoMeta jczhuoMeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Thank you for adding the tests

@sol-loup sol-loup changed the title test coverage 03 05 25 Add Unit Tests for AsyncRequest Class Mar 6, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@sol-loup has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@sol-loup merged this pull request in b59461b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants