Skip to content

Tests: Strengthen wp_ext2type() coverage - #15278

Open
shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/wp-ext2type-65819
Open

shail-mehta wants to merge 3 commits into
WordPress:trunkfrom
shail-mehta:tests/wp-ext2type-65819

Conversation

@shail-mehta

@shail-mehta shail-mehta commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

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:

  • Assert literal mappings for jpg/PNG → image, mp3 → audio, mp4 → video, and pdf → document
  • Add @covers ::wp_ext2type

Testing Instructions

  1. npm run test:php -- --filter test_wp_ext2type
  2. npm run test:php -- --filter test_wp_ext2type -c tests/phpunit/multisite.xml
  3. npm run test:php -- --filter test_wp_ext2type --order-by=random
  4. npm run test:php -- --group functions

Use of AI Tools

  • Cursor

Add unit tests for known extension type mapping and unknown extensions.\n\nSee #65819.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@shail-mehta
shail-mehta marked this pull request as ready for review October 31, 2026 17:28
@github-actions

github-actions Bot commented Oct 31, 2026 •

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shailu25, lancewillett.

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.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Existing coverage.

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.
@shail-mehta shail-mehta changed the title Tests: Add unit coverage for wp_ext2type() Tests: Strengthen wp_ext2type() coverage Nov 1, 2026
@shail-mehta
shail-mehta requested a balanced review from Copilot November 1, 2026 05:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the added extension-to-type test coverage.

No open issues 🎉

Review effort: Balanced

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.

3 participants