[wp-trac] [WordPress Trac] #61851: Unit tests should typically not use `wp_delete_user()` to delete users for multisite compatibility

WordPress Trac noreply at wordpress.org
Fri Aug 9 18:11:33 UTC 2024


#61851: Unit tests should typically not use `wp_delete_user()` to delete users for
multisite compatibility
------------------------------+-------------------------
 Reporter:  flixos90          |      Owner:  flixos90
     Type:  enhancement       |     Status:  assigned
 Priority:  low               |  Milestone:  6.7
Component:  Build/Test Tools  |    Version:
 Severity:  minor             |   Keywords:  needs-patch
  Focuses:  multisite         |
------------------------------+-------------------------
 Several PHPUnit tests rely on `wp_delete_user()` to delete temporarily
 created users. However, when using WordPress Multisite,
 `wpmu_delete_user()` needs to be used instead. For this purpose, the
 WordPress test base class provides a static method `delete_user( $user_id
 )`, which abstracts away this detail.

 All PHPUnit tests should use this static method instead of
 `wp_delete_user()`, unless the test is explicitly excluding multisite or
 testing a behavior of `wp_delete_user()` with consideration of how it
 behaves differently with a multisite network.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61851>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list