Repository navigation
Tests: Add unit tests for wp_start_scraping_edited_file_errors() - #14483
shail-mehta wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The early-return tests need process isolation to prevent failures caused by constants defined by earlier tests.
1 open issue
What changed in this PR
Adds dedicated PHPUnit coverage for wp_start_scraping_edited_file_errors() as part of ticket #65819, without changing production code.
Changes:
- Tests early returns for missing or empty request parameters and a missing transient.
- Tests sandbox activation when the nonce matches.
| File | Description |
|---|---|
| tests/phpunit/tests/load/wpStartScrapingEditedFileErrors.php | Adds four tests with request and transient cleanup. |
Review effort: Balanced
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
The assertions match wp_start_scraping_edited_file_errors(). Two points about process isolation inline.
| * | ||
| * @group load | ||
| * | ||
| * @runTestsInSeparateProcesses |
There was a problem hiding this comment.
Only the last test defines WP_SANDBOX_SCRAPING, and it already has @runInSeparateProcess. The first three tests assert that the constant is not defined, so they can run in the normal process. Could this class-level @runTestsInSeparateProcesses and @preserveGlobalState disabled be removed?
| $_REQUEST['wp_scrape_key'] = $key; | ||
| $_REQUEST['wp_scrape_nonce'] = $nonce; | ||
|
|
||
| wp_start_scraping_edited_file_errors(); |
There was a problem hiding this comment.
When the nonce matches, this call registers wp_finalize_scraping_edited_file_errors() as a shutdown function. That function prints the scrape markers when the child process exits, after PHPUnit has written the test result. It works today, but it adds output to the child process result. Could the test remove that output, or note in a comment why it is safe?
There was a problem hiding this comment.
Done in latest commits.
lancewillett
left a comment
There was a problem hiding this comment.
The early-return cases preserve constant state, with process isolation limited to the successful registration case.
The unit-tests audit is complete. This class passed independently, and the ten-PR batch passed randomized single-site and multisite runs (61 tests, 95 assertions each). PHPCS passed. I also reviewed the fresh Copilot feedback.
AI review · gpt-6
|
PR #14483 landed in https://core.trac.wordpress.org/changeset/64562 |
Cover early returns and successful registration in `wp_start_scraping_edited_file_errors()`. Isolate the case that defines a constant and registers a shutdown callback. Developed in: #14483 Props shailu25, mukesh27. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64562 602fd350-edb4-49c9-b593-d223f7449a82
Cover early returns and successful registration in `wp_start_scraping_edited_file_errors()`. Isolate the case that defines a constant and registers a shutdown callback. Developed in: WordPress/wordpress-develop#14483 Props shailu25, mukesh27. See #65819. Built from https://develop.svn.wordpress.org/trunk@64562 git-svn-id: http://core.svn.wordpress.org/trunk@63712 1a063a9b-81f0-0310-95a4-ce76da25c4cd

What
Trac ticket: #65819
Adds unit tests for
wp_start_scraping_edited_file_errors()intests/phpunit/tests/load/wpStartScrapingEditedFileErrors.php.Covers missing/empty scrape params, a missing scrape transient, and a matching nonce that enables sandbox scraping.
Test-only change.
Why
This helper has had no dedicated PHPUnit coverage. Fits the #65819 missing-coverage track, and no open PR covers it.
How
WP_SANDBOX_SCRAPINGwhen the scrape key and nonce matchTesting instructions
Use of AI Tools