Skip to content

Coding Standards: Fix parameter docs in test methods for clarity and consistency - #12208

Open
Soean wants to merge 14 commits into
WordPress:trunkfrom
Soean:fix_test_docs
Open

Coding Standards: Fix parameter docs in test methods for clarity and consistency#12208
Soean wants to merge 14 commits into
WordPress:trunkfrom
Soean:fix_test_docs

Conversation

@Soean

@Soean Soean commented Jun 17, 2026

Copy link
Copy Markdown
Member

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.

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props soean, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

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,
The WordPress Project

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Comment thread tests/phpunit/tests/dependencies/scripts.php Outdated
Comment thread tests/phpunit/tests/functions/allowedProtocols.php Outdated
@mukeshpanchal27

Copy link
Copy Markdown
Member

@Soean You can link this PR to Core-64894 ticket.

Soean and others added 2 commits June 18, 2026 13:46
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 30, 2026 17:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 @param variable names to match method signatures and actual usage.
  • Removes outdated @param entries 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.

Comment thread tests/phpunit/tests/admin/includesFile.php Outdated
Comment thread tests/phpunit/tests/filesystem/wpFilesystemDirect/delete.php Outdated
Comment thread tests/phpunit/tests/dependencies/scripts.php Outdated
Comment thread tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 30, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 $expected parameter is documented as bool, 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 $filter argument is passed to add_filter( 'pre_http_request', $filter ) and the data provider yields closures, so the parameter type should be callable rather than string.
	 * @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) use self::$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`.

Soean added 3 commits July 30, 2026 19:58
…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.
Copilot AI review requested due to automatic review settings July 30, 2026 18:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_methods is present here, but test_prepare_item() does not accept a $method argument 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 $method parameter).
	/**
	 * @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' in do_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
	 */

Copilot AI review requested due to automatic review settings July 30, 2026 18:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 from self::$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 $path variable) before calling delete() 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.' );

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants