Make WordPress Core

#50986 closed defect (bug) (fixed)

PHPUnit tests: unregister custom settings after rest-api tests

Reported by: david.binda Owned by: SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: minor Version: 4.7
Component: REST API Keywords:
Focuses: Cc:


Most of the tests in tests/phpunit/tests/rest-api/rest-settings-controller.php are removing the settings they after performing the assertions.

However, not all of them do, which means that those settings may be leaking to other tests. This is not breaking any tests at the moment, but may cause issues when the order of the tests changes.

Attachments (1)

50986.diff (1.4 KB) - added by david.binda 16 months ago.

Download all attachments as: .zip

Change History (3)

16 months ago

#1 @TimothyBlynJacobs
16 months ago

  • Component changed from General to REST API
  • Milestone changed from Awaiting Review to 5.6
  • Version set to 4.7

Thanks for the patch @davidbinda!

Could we move all the unregister_setting calls to tearDown? That way we can guarantee they get executed if an assertion fails?

#2 @SergeyBiryukov
16 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48791:

Tests: Consistently unregister custom settings after performing assertions in WP_Test_REST_Settings_Controller.

This ensures that those settings don't leak to other tests.

Props david.binda, TimothyBlynJacobs, SergeyBiryukov.
Fixes #50986.

Note: See TracTickets for help on using tickets.