Coding Standards: Fix parameter docs in test methods for clarity and consistency - #12208
Coding Standards: Fix parameter docs in test methods for clarity and consistency#12208Soean wants to merge 14 commits into
Conversation
|
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. |
|
Hi there! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@Soean You can link this PR to Core-64894 ticket. |
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request standardizes and corrects PHPUnit test PHPDoc blocks (primarily @param tags) to better reflect actual parameter names/usages and to remove stale docs from tests that no longer accept parameters.
Changes:
- Renames/aligns PHPDoc
@paramvariable names to match method signatures and actual usage. - Removes outdated
@paramentries from parameterless test methods. - Improves consistency of docblocks across multiple test suites (REST API, filesystem, privacy, etc.).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/phpunit/tests/rewrite.php | Aligns filter callback PHPDoc param name with the method signature. |
| tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php | Removes stale @param docs from a parameterless test. |
| tests/phpunit/tests/rest-api/rest-search-controller.php | Removes stale @param docs from a parameterless test. |
| tests/phpunit/tests/rest-api/rest-comments-controller.php | Corrects PHPDoc param to reflect role-based input for helper method. |
| tests/phpunit/tests/rest-api/rest-block-type-controller.php | Removes stale @param docs from a parameterless test. |
| tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php | Adds missing parameter names to PHPUnit data-provider-driven tests and adjusts formatting. |
| tests/phpunit/tests/post.php | Removes stale @param docs from a parameterless test. |
| tests/phpunit/tests/multisite/updateBlogDetails.php | Renames PHPDoc param to match $hook usage in the test method. |
| tests/phpunit/tests/image/meta.php | Adds missing parameter names to stream metadata test PHPDoc. |
| tests/phpunit/tests/functions/doEnclose.php | Renames PHPDoc param to match $enclosure_links argument. |
| tests/phpunit/tests/functions/allowedProtocols.php | Adds missing parameter names to protocol/url data-provider test PHPDoc. |
| tests/phpunit/tests/filesystem/wpFilesystemDirect/isDir.php | Removes stale/mismatched PHPDoc params no longer present in the test signature. |
| tests/phpunit/tests/filesystem/wpFilesystemDirect/delete.php | Renames PHPDoc param variable name for clarity in delete test. |
| tests/phpunit/tests/dependencies/scripts.php | Updates PHPDoc param list for eligible strategy filtering test. |
| tests/phpunit/tests/admin/includesFile.php | Renames PHPDoc params for clarity in download_url() tests. |
Comments suppressed due to low confidence (1)
tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php:425
- This docblock has an extra blank
*line before the closing*/, which is inconsistent with the surrounding docblocks and adds noise.
* @param bool $send_as_email Whether the final results of the export should be emailed to the user.
*
*/
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
tests/phpunit/tests/dependencies/scripts.php:562
- The
$expectedparameter is documented asbool, but the data provider returns arrays of eligible strategies (e.g.array( 'defer' )/array( 'defer', 'async' )). This makes the docblock inaccurate and potentially confusing when reading the test.
* @param callable $set_up Set up.
* @param bool $expected Expected return value.
*/
tests/phpunit/tests/admin/includesFile.php:403
- The
$filterargument is passed toadd_filter( 'pre_http_request', $filter )and the data provider yields closures, so the parameter type should becallablerather thanstring.
* @param string $filter A callback containing a fake Content-Type header.
* @param string $extension The expected file extension to match.
tests/phpunit/tests/filesystem/wpFilesystemDirect/delete.php:72
- The docblock references
self::$filesystem_structure, but this test (and related tests) useself::$file_structure. The current reference appears to be a typo and doesn't match the actual property name.
* @param string $file The key for the file in `self::$filesystem_structure`.
…f strategy strings (e.g. array( 'defer', 'async' )), not a boolean, so the PHPDoc type is incorrect
…_should_use_the_content_type_header_to_set_extension_of_a_file_if_extension_was_not_determined()), so the parameter type should be callable rather than string.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
tests/phpunit/tests/rest-api/rest-block-type-controller.php:756
@dataProvider data_readable_http_methodsis present here, buttest_prepare_item()does not accept a$methodargument and does not vary behavior based on the provider values. This makes the annotation misleading and can create argument-count problems in stricter PHPUnit configurations. Remove the data provider annotation (or add/use a$methodparameter).
/**
* @dataProvider data_readable_http_methods
* @ticket 47620
* @ticket 56481
*/
tests/phpunit/tests/rest-api/rest-search-controller.php:360
- This test is annotated with
@dataProvider data_readable_http_methods, but the method signature accepts no parameters and always uses the default'GET'indo_request_with_params(). That means the data provider values are unused and (depending on PHPUnit behavior/version) can also cause argument-count issues. Either remove the data provider annotation or update the test to accept and use$method.
* Search through posts of an invalid post type.
*
* @dataProvider data_readable_http_methods
* @ticket 56481
*/
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/phpunit/tests/filesystem/wpFilesystemDirect/delete.php:78
test_should_delete_a_file()constructs the file path incorrectly by appending the file key to the already-complete path fromself::$file_structure[$file]['path']. This can cause the test to pass without actually deleting the intended fixture file (because the computed path may not exist). Use the stored path directly (or assign it to a separate$pathvariable) before callingdelete()and assertions.
public function test_should_delete_a_file( $file ) {
$file = self::$file_structure[ $file ]['path'] . $file;
$this->assertTrue( self::$filesystem->delete( $file ), 'File deletion failed.' );
$this->assertFileDoesNotExist( $file, 'The file was not deleted.' );
This pull request updates and clarifies parameter names and docblocks in various PHPUnit test files to improve code readability and maintainability. The changes primarily focus on making parameter names more descriptive and aligning them with their actual usage in the test methods.
These updates do not affect test logic but enhance code quality and developer experience by making the test suite easier to understand and maintain.
Trac ticket: https://core.trac.wordpress.org/ticket/64894
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.