WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#28579 closed enhancement (fixed)

Add unit tests (phpunit, qunit) for Customizer

Reported by: westonruter Owned by:
Milestone: 4.3 Priority: normal
Severity: normal Version: 3.4
Component: Customize Keywords: needs-patch
Focuses: javascript Cc:

Description

There is a lot of code in the Customizer, and it is completely lacking any PHP or JS unit tests. The only unit tests that currently reference the Customizer are:

  • phpunit/tests/theme/WPTheme.php
  • qunit/wp-admin/js/customize-header.js

But there is a lot of constructs in the Customizer which are completely untested. We need phpunit and qunit tests for the various aspects of the Customizer to ensure we don't introduce regressions when we extend it to manage more parts of WordPress.

Change History (11)

This ticket was mentioned in IRC in #wordpress-dev by westonruter. View the logs.


5 years ago

#2 @westonruter
5 years ago

Tests were added for widget customizer in [27492] but then were reverted in [27493].

#3 @westonruter
5 years ago

I've started writing some initial QUnit tests as part of the work on #28709.

#4 @ocean90
5 years ago

In 30102:

Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.

  • Introduce models for panels and sections.
  • Introduce API to expand and focus a control, section or panel.
  • Allow deep-linking to panels, sections, and controls inside of the Customizer.
  • Clean up accordion.js, removing all Customizer-specific logic.
  • Add initial unit tests for wp.customize.Class in customize-base.js.

https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.

props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.

#5 @westonruter
5 years ago

Additional unit tests are being worked on in this pull request: https://github.com/xwpco/wordpress-develop/pull/46

#7 @westonruter
5 years ago

I just added quite a few more qunit tests in https://core.trac.wordpress.org/ticket/30701#comment:3

#8 @westonruter
5 years ago

First PHPUnit tests for WP_Customize_Setting submitted in https://core.trac.wordpress.org/ticket/30988#comment:5

This ticket was mentioned in Slack in #core by ocean90. View the logs.


5 years ago

This ticket was mentioned in Slack in #core-customize by ocean90. View the logs.


4 years ago

#11 @westonruter
4 years ago

  • Milestone changed from Future Release to 4.3
  • Resolution set to fixed
  • Status changed from new to closed

We've made a lot of progress here. I'm happy to close this out with the tests added in 4.3, although there's always room for more tests.

Note: See TracTickets for help on using tickets.