Skip to content

Tests: Add unit tests for wp_get_active_and_valid_themes() - #14482

Open
shail-mehta wants to merge 2 commits into
WordPress:trunkfrom
shail-mehta:65819-add-wp-get-active-and-valid-themes-tests
Open

shail-mehta wants to merge 2 commits into
WordPress:trunkfrom
shail-mehta:65819-add-wp-get-active-and-valid-themes-tests

Conversation

@shail-mehta

Copy link
Copy Markdown
Member

What

Trac ticket: #65819

Adds unit tests for wp_get_active_and_valid_themes() in tests/phpunit/tests/load/wpGetActiveAndValidThemes.php.

Covers parent/child themes, installing mode, wp-activate.php, and paused themes in recovery mode.

Test-only change.

Why

This helper has had no dedicated PHPUnit coverage. Fits the #65819 missing-coverage track, and no open PR covers it.

How

  • Return the template path for a parent theme
  • Include the stylesheet path for a child theme
  • Return an empty list while installing, except on wp-activate.php
  • Skip paused themes in recovery mode and disable themes when none remain

Testing instructions

npm run test:php -- --filter Tests_Load_WpGetActiveAndValidThemes

Use of AI Tools

  • Cursor

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

Static review found no blocking issues in this test-only change; tests were not executed.

No open issues 🎉

What changed in this PR

Adds dedicated PHPUnit coverage for wp_get_active_and_valid_themes() under ticket #65819. No production code changes.

Changes:

  • Tests parent and child theme paths.
  • Covers installation mode and the wp-activate.php exception.
  • Verifies paused-theme handling in recovery mode.
File Description
tests/​phpunit/​tests/​load/​wpGetActiveAndValidThemes.php Adds six tests with state setup and cleanup.

Review effort: Balanced

@shail-mehta
shail-mehta marked this pull request as ready for review October 19, 2026 09:21
@github-actions

github-actions Bot commented Oct 19, 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. You can also manually ask me to refresh this list by adding the props-bot label.

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

Props shailu25, mukesh27.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

global $wp_stylesheet_path, $wp_template_path;

$wp_template_path = get_theme_root() . '/twentytwentyone';
$wp_stylesheet_path = get_theme_root() . '/twentytwentyfive';

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.

Optional: twentytwentyfive is not really a child theme of twentytwentyone. The test works because is_child_theme() only compares the two paths. A one-line comment saying that would help readers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added One line comment in e661b71

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