Make WordPress Core

Opened 10 hours ago

Last modified 9 hours ago

#65184 new enhancement

Tests: Add unit tests for admin_color_scheme_picker()

Reported by: pbearne's profile pbearne Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

This ticket adds unit tests for the admin_color_scheme_picker() function in wp-admin/includes/misc.php. The tests will cover the correct sorting of color schemes, the default selection, and the HTML output generation including nonces and radio buttons.

Change History (1)

This ticket was mentioned in PR #11740 on WordPress/wordpress-develop by @pbearne.


9 hours ago
#1

  • Keywords has-patch has-unit-tests added

…isc.php
Description:
This PR adds unit tests for the admin_color_scheme_picker() function in wp-admin/includes/misc.php. These tests ensure that the function correctly displays the administration color scheme picker, handles user preferences, and maintains the expected sorting order of color schemes.

The tests cover:

  • Default selection of the "modern" color scheme when no user preference is set.
  • Correct selection of a custom color scheme when set in user meta.
  • Fallback to the "modern" scheme when an invalid color scheme is stored.
  • Proper sorting of schemes, ensuring "modern", "fresh", and "light" appear first.
  • Verification of the generated HTML structure, including fieldsets, labels, radio buttons, and hidden inputs containing theme data.

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

AI Disclosure:

  • AI assistance: Yes
  • Tool(s): Junie (JetBrains)
  • Model(s): gemini-3-flash-preview
  • Used for: Code analysis, test implementation, and workflow management.
Note: See TracTickets for help on using tickets.