Repository navigation
Tests: Extend wp_get_default_extension_for_mime_type() coverage - #15279
shail-mehta wants to merge 3 commits into
Conversation
Add unit tests for known mime-to-extension mapping and unknown mime types.\n\nSee #65819.
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for this test-only addition covering default extensions for known and unknown MIME types.
No open issues 🎉
What changed in this PR
Adds dedicated PHPUnit coverage for wp_get_default_extension_for_mime_type() as part of the #65819 test cleanup effort. No production code changes.
Changes:
- Adds a test class with an explicit
@coversannotation. - Checks the first mapped extension for JPEG, PNG, PDF, and MP3 MIME types.
- Verifies that an unknown MIME type returns
false.
| File | Description |
|---|---|
tests/phpunit/tests/functions/wpGetDefaultExtensionForMimeType.php |
Adds data-driven tests for known MIME types and a test for unknown MIME types. |
Review effort: Balanced
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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:
|
lancewillett
left a comment
There was a problem hiding this comment.
Please extend the existing Tests_Functions::test_wp_get_default_extension_for_mime_type() at tests/phpunit/tests/functions.php:2269–2277 instead. It already covers JPEG's first-extension choice, PNG, and unknown MIME types. PDF/MP3 are new literal rows, but do not require duplicating those existing scenarios in a second class.
This is a request to keep the coverage lean, not a reported runtime regression.
AI review · gpt-6
Add PDF and MP3 first-extension assertions to the existing helper test and drop the dedicated class. See #65819.
wp_get_default_extension_for_mime_type()|
Thanks for the review! Addressed in 4378927 |
lancewillett
left a comment
There was a problem hiding this comment.
The revised patch addresses the earlier review requests.
Validated with the related helper patches on current trunk, randomized seed 1101: single-site 773 tests / 1,831 assertions; multisite 764 / 1,822. No failures or errors. The two existing PHPUnit warning-expectation deprecations and one skip were unchanged from the baseline.
Current-head CI and Copilot review checked.
AI review · gpt-6
Add literal extension-to-type and MIME-to-extension expectations to the existing tests for `wp_ext2type()` and `wp_get_default_extension_for_mime_type()`. Developed in: #15278, #15279 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65164 602fd350-edb4-49c9-b593-d223f7449a82
Add literal extension-to-type and MIME-to-extension expectations to the existing tests for `wp_ext2type()` and `wp_get_default_extension_for_mime_type()`. Developed in: WordPress/wordpress-develop#15278, WordPress/wordpress-develop#15279 Props shailu25. See #65819. Built from https://develop.svn.wordpress.org/trunk@65164 git-svn-id: http://core.svn.wordpress.org/trunk@64313 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #15279 landed in https://core.trac.wordpress.org/changeset/65164 |
Trac ticket: #65819
What
Extends the existing
Tests_Functions::test_wp_get_default_extension_for_mime_type()coverage with PDF and MP3 mime-to-extension mappings.Test-only; no production code changes.
Why
JPEG, PNG, and unknown mime types were already covered. PDF and MP3 first-extension rows were missing and fit the #65819 cleanup track without a second class.
How
Update
tests/phpunit/tests/functions.php:application/pdf→pdfaudio/mpeg→mp3@covers ::wp_get_default_extension_for_mime_typeTesting Instructions
npm run test:php -- --filter test_wp_get_default_extension_for_mime_typenpm run test:php -- --filter test_wp_get_default_extension_for_mime_type -c tests/phpunit/multisite.xmlnpm run test:php -- --filter test_wp_get_default_extension_for_mime_type --order-by=randomnpm run test:php -- --group functionsUse of AI Tools