Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks 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: tests 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 (2)

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


6 weeks 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.

#2 @desrosj
5 weeks ago

  • Focuses tests added

Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.

Note: See TracTickets for help on using tickets.