Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#50986 closed defect (bug) (fixed)

PHPUnit tests: unregister custom settings after rest-api tests

Reported by: davidbinda's profile david.binda Owned by: sergeybiryukov's profile 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 4 years ago.

Download all attachments as: .zip

Change History (3)

4 years ago

#1 @TimothyBlynJacobs
4 years 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
4 years 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.