Skip to content

Tests: Add unit tests for get_header_video_settings(). - #16189

Closed
rejaulalomkhan wants to merge 2 commits into
WordPress:trunkfrom
rejaulalomkhan:tests/theme-get-header-video-settings
Closed

rejaulalomkhan wants to merge 2 commits into
WordPress:trunkfrom
rejaulalomkhan:tests/theme-get-header-video-settings

Conversation

@rejaulalomkhan

@rejaulalomkhan rejaulalomkhan commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

Adds dedicated unit tests for get_header_video_settings() in src/wp-includes/theme.php, which was introduced in [38985] (#38172) but lacked dedicated unit tests.

The data provider exercises eight URLs: three YouTube formats, three direct video files, an unknown extension, and an empty URL. Each case checks the MIME type and video URL used by the header player.

Testing Instructions

Run single-site and multisite test suites and coding standards:

node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit tests/phpunit/tests/theme/getHeaderVideoSettings.php
node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit -c tests/phpunit/multisite.xml tests/phpunit/tests/theme/getHeaderVideoSettings.php
node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpcs tests/phpunit/tests/theme/getHeaderVideoSettings.php

Trac ticket: https://core.trac.wordpress.org/ticket/66825


This Pull Request is for code review only. Please keep all other discussion to the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Use of AI Tools

AI assistance: Yes
Tool(s): Google Antigravity
Model(s): Gemini 3.8 Flash
Used for: Identifying untested theme function, authoring PHPUnit test cases, and running verification suites locally. I reviewed every line, ran the tests, and take responsibility for the change.

Cover default settings structure, YouTube mimeType resolution, direct video filetype detection, and header_video_settings filter.

See #38172.
@github-actions

github-actions Bot commented Nov 24, 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 rejaulalomkhan, 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 or WordPress.org 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.

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.

🟡 Changes recommended

The new tests use @group theme instead of @group themes, excluding them from targeted PHPUnit theme runs.

1 open issue
What changed in this PR

Adds dedicated PHPUnit coverage for get_header_video_settings(), strengthening tests for WordPress custom-header video settings without changing production code.

Changes:

  • Checks the default settings structure, playback thresholds, and localization keys.
  • Covers YouTube URL variants and direct MP4 MIME detection and URL handling.
  • Verifies that the header_video_settings filter can modify and extend settings.
File Description
tests/​phpunit/​tests/​theme/​getHeaderVideoSettings.php Adds six test cases covering defaults, video sources, and settings filtering.

Review effort: Balanced

@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.

The useful regression here is choosing the right player for YouTube and direct video URLs. Could you focus on the URL-to-MIME cases and drop the default-array inventory? Please also remove the blanket remove_all_filters() teardown. The base test case restores the hooks after each test.

Please use the existing themes test group and link any retained coverage to an open component ticket. The historical ticket can stay as context.

AI review · gpt-6

@rejaulalomkhan

Copy link
Copy Markdown
Member Author

Thanks for the review and guidance, @lancewillett! Updated per your feedback:

  • Switched @group theme to @group themes.
  • Dropped the default-array inventory test and removed the blanket remove_all_filters() teardown.
  • Consolidated the suite to focus exclusively on URL-to-MIME resolution across YouTube variants, direct video files (.mp4, .webm, .mov), unrecognized extensions, and unconfigured URLs via a clean data provider.

All single-site, multisite, and reverse-order tests pass with 0 PHPCS errors.

AI assistance · Gemini 3.8 Flash

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.

🟡 Changes recommended

The tests assert only mimeType and videoUrl, leaving the default-settings structure and header_video_settings filter coverage claimed in the PR description untested.

1 open issue
1 resolved since last review

Review effort: Balanced

@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.

This now tests the MIME type the header player actually uses. Removing the YouTube mapping failed the three YouTube cases locally. The shared test harness restores the filter after each case, so dropping the blanket teardown was the right change.

The code looks ready. As Copilot spotted, the description still promises default settings and filter coverage. Please update the description to match this narrower test. Please link the open Themes coverage ticket before landing; #38172 records the original feature.

AI review · gpt-6

wporg-sync pushed a commit that referenced this pull request Nov 25, 2026
Cover the MIME type and video URL returned by `get_header_video_settings()` for YouTube, direct video files and an unset URL.

Developed in: #16189

Follow-up to r38985.

Props rejaulalomkhan.
Fixes #66825.


git-svn-id: https://develop.svn.wordpress.org/trunk@65786 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 65786
GitHub commit: c339583

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Nov 25, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 25, 2026
Cover the MIME type and video URL returned by `get_header_video_settings()` for YouTube, direct video files and an unset URL.

Developed in: WordPress/wordpress-develop#16189

Follow-up to r38985.

Props rejaulalomkhan.
Fixes #66825.

Built from https://develop.svn.wordpress.org/trunk@65786


git-svn-id: http://core.svn.wordpress.org/trunk@64815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants