Skip to content

Tests: Cover the wp_delete_file filter in wp_delete_file() - #14890

Open
bluefairydevelopment wants to merge 1 commit into
WordPress:trunkfrom
bluefairydevelopment:tests/59788-wp-delete-file-filter
Open

bluefairydevelopment wants to merge 1 commit into
WordPress:trunkfrom
bluefairydevelopment:tests/59788-wp-delete-file-filter

Conversation

@bluefairydevelopment

Copy link
Copy Markdown

Trunk's tests/phpunit/tests/functions/wpDeleteFile.php (added under #61590) already covers deleting a file, an empty path and a missing file. The wp_delete_file filter itself has no coverage. This adds the two filter cases:

  • test_wp_delete_file_does_not_delete_when_filter_returns_empty: the filter returns an empty path, wp_delete_file() returns false and the file stays.
  • test_wp_delete_file_deletes_the_filtered_path: the filter returns a different path, that path is deleted and the original is left alone.

This builds on pbearne's earlier PR #5611, which proposed the filter test before the #61590 tests landed. These are written against the current test file, using wp_tempnam() and cleaning up after themselves.

Verification: both tests pass, phpcs is clean, and when wp_delete_file() was changed to ignore the filter, exactly these two tests failed while the existing three still passed.

Props pbearne.

Trac ticket: https://core.trac.wordpress.org/ticket/59788

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: comparing the ticket, the open PR and trunk, writing the tests, and checking that they fail when the filter is ignored. Submitted by Blue Fairy Development, who are responsible for the change.


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.

Add tests that an empty filtered path skips deletion and that a changed
filtered path is the one deleted.

Props pbearne.
See #59788.
@github-actions

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @bluefairydevelopment.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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.

1 participant