Repository navigation
Tests: Strengthen wp_ext2type() coverage - #15278
shail-mehta wants to merge 3 commits into
Conversation
Add unit tests for known extension type mapping and unknown extensions.\n\nSee #65819.
There was a problem hiding this comment.
🟢 Approval recommended
The change adds dedicated wp_ext2type() test coverage, with no active review issues identified.
No open issues 🎉
What changed in this PR
Adds direct PHPUnit coverage for wp_ext2type() as part of the test cleanup work in Trac #65819. No production code changes.
Changes:
- Adds a dedicated test class with
@covers ::wp_ext2type. - Checks known extension mappings and uppercase normalization.
- Verifies that an unknown extension returns
null.
| File | Description |
|---|---|
tests/phpunit/tests/functions/wpExt2type.php |
Adds data-driven mapping tests and an unknown-extension test. |
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 consolidate this with Tests_Functions::test_wp_ext2type() in tests/phpunit/tests/functions.php:1151–1164. That test already checks all registered extensions in both cases and the unknown result. The literal mappings add independence from the registry, but can strengthen the existing test without repeating the same lookup scenarios in another class.
This is a request to keep the coverage lean, not a reported runtime regression.
AI review · gpt-6
Add literal extension mappings to the existing helper test and drop the dedicated class. See #65819.
wp_ext2type()
Trac ticket: #65819
What
Strengthens the existing
Tests_Functions::test_wp_ext2type()coverage with literal extension-to-type mappings that stay independent of the registry.Test-only; no production code changes.
Why
The existing test already walks all registered extensions and the unknown result. A few literal rows add independence from the registry without a second class, and fit the #65819 cleanup track.
How
Update
tests/phpunit/tests/functions.php:jpg/PNG→image,mp3→audio,mp4→video, andpdf→document@covers ::wp_ext2typeTesting Instructions
npm run test:php -- --filter test_wp_ext2typenpm run test:php -- --filter test_wp_ext2type -c tests/phpunit/multisite.xmlnpm run test:php -- --filter test_wp_ext2type --order-by=randomnpm run test:php -- --group functionsUse of AI Tools