Repository navigation
Conversation
costdev
left a comment
There was a problem hiding this comment.
Thanks for writing these tests Paul!
I have made some suggestions to improve consistency, readability and coverage in the tests.
| 'filename' => 'filename.png', | ||
| 'files' => array( 'filename-rotated.png' ), | ||
| 'expected' => true, | ||
| ), |
There was a problem hiding this comment.
There should be two additional datasets:
'a file with no extension'that tests a'filename'such asfilename-expectedshould betrue.- This covers filenames that don't match this branch.
'a file with no filename'that tests a'filename'such as.htaccess-expectedshould befalse.- This covers this branch.
There was a problem hiding this comment.
both of these return false
because of this code
// Edge case, file names like .ext.
if ( empty( $fname ) || empty( $ext ) ) {
return false;
}
Do you feel the code should changed to return true?
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
…mes' into #53971_wp_check_existing_file_names # Conflicts: # tests/phpunit/tests/functions/_wpCheckExistingFileNames.php
costdev
left a comment
There was a problem hiding this comment.
Looks great Paul! Just two suggestions to use a single underscore _ instead of two underscores __ in the method names.
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change adding filename-conflict test coverage.
No open issues 🎉
What changed in this PR
Adds PHPUnit coverage for _wp_check_existing_file_names(), WordPress’s helper for detecting filename conflicts with generated image variants, in support of Trac ticket #55192.
Changes:
- Adds data-driven tests for dimension, scaled, and rotated suffixes, plus filenames without a name or extension.
- Adds a blank line in the helper; production behavior is unchanged.
| File | Description |
|---|---|
tests/phpunit/tests/functions/_wpCheckExistingFileNames.php |
Adds ten test cases for filename matching and edge cases. |
src/wp-includes/functions.php |
Whitespace-only change in the empty-filename guard. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The requested naming changes are present. All ten cases passed locally in randomized single-site and multisite runs; Copilot also found no active issue.
On the older extensionless-filename question: no production change is needed. filename against filename correctly returns false; filename against filename-1x1 returns true with the current implementation. That latter row would clarify the earlier discussion, but I do not consider it necessary before landing this coverage.
AI review · gpt-6
|
One landing prerequisite remains: GitHub currently reports no checks for this head. Could you refresh the branch so current CI runs? The local test review is approved. AI review · |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @mauriac. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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. |
Test `_wp_check_existing_file_names()` against image dimensions, scaled and rotated suffixes, and filenames without a basename or extension. Developed in: #2332 Props pbearne, azouamauriac, costdev. Fixes #55192. git-svn-id: https://develop.svn.wordpress.org/trunk@65154 602fd350-edb4-49c9-b593-d223f7449a82
Test `_wp_check_existing_file_names()` against image dimensions, scaled and rotated suffixes, and filenames without a basename or extension. Developed in: WordPress/wordpress-develop#2332 Props pbearne, azouamauriac, costdev. Fixes #55192. Built from https://develop.svn.wordpress.org/trunk@65154 git-svn-id: http://core.svn.wordpress.org/trunk@64303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
done |
test for _wp_check_existing_file_names
Trac ticket:https://core.trac.wordpress.org/ticket/55192