#59788 closed enhancement (fixed)
test for wp_delete_file
| Reported by: | pbearne | Owned by: | lancewillett |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Filesystem API | Version: | |
| Severity: | normal | Keywords: | has-unit-tests has-patch |
| Cc: | Focuses: | tests |
Description
Change History (8)
This ticket was mentioned in PR #5611 on WordPress/wordpress-develop by @pbearne.
3 years ago
#1
- Keywords has-patch has-unit-tests added
#3
@
2 years ago
- Component Build/Test Tools → Filesystem API
- Keywords has-unit-tests added
- Milestone Awaiting Review → Future Release
- Type defect (bug) → enhancement
#4
@
6 months ago
- Focuses tests added
Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.
This ticket was mentioned in PR #14890 on WordPress/wordpress-develop by bluefairydevelopment.
12 days ago
#5
- Keywords has-patch added
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()returnsfalseand 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.
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Since this is about adding tests and not a general build or test tooling change, I'm reassigning it to the relevant component.