From da5c716009e3c2fa87ec0f4c5b9a38fb52aced44 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 26 Jun 2015 12:58:29 +0000 Subject: [PATCH] Introduce `WP_UnitTestCase::delete_user()`. This static method provides a multisite-agnostic way to delete users during automated testing. See #32796. git-svn-id: https://develop.svn.wordpress.org/trunk@32953 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 35d0a62e54..b93149f4b1 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -597,4 +597,17 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { public function tear_down_wp_mail_globals() { unset( $_SERVER['SERVER_NAME'] ); } + + /** + * Multisite-agnostic way to delete a user from the database. + * + * @since 4.3.0 + */ + public static function delete_user( $user_id ) { + if ( is_multisite() ) { + return wpmu_delete_user( $user_id ); + } else { + return wp_delete_user( $user_id ); + } + } }