Unit Tests:

* Automatically delete objects that we were created during `wpSetUpBeforeClass` - posts, comments, terms (except 1), and user (except 1)
* The amount of leftover data between tests was breathtaking - use the new function: `_delete_all_data()`
* Commit database transactions for all `TestCase`s, not just those that implement `wpSetUpBeforeClass` and `wpTearDownAfterClass`
* The tests run 10-20 seconds faster now

See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38398 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2016-08-27 08:35:16 +00:00
parent f0af25bd80
commit 02319efa71
51 changed files with 60 additions and 371 deletions

View File

@ -48,13 +48,47 @@ function _test_filter_build_unique_id($tag, $function, $priority) {
}
}
function _delete_all_data() {
global $wpdb;
foreach ( array(
$wpdb->posts,
$wpdb->postmeta,
$wpdb->comments,
$wpdb->commentmeta,
$wpdb->term_relationships,
$wpdb->termmeta
) as $table ) {
$wpdb->query( "DELETE FROM {$table}" );
}
foreach ( array(
$wpdb->terms,
$wpdb->term_taxonomy
) as $table ) {
$wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" );
}
$wpdb->query( "UPDATE {$wpdb->term_taxonomy} SET count = 0" );
$wpdb->query( "DELETE FROM {$wpdb->users} WHERE ID != 1" );
$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id != 1" );
}
function _delete_all_posts() {
global $wpdb;
$all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}");
if ($all_posts) {
foreach ($all_posts as $id)
wp_delete_post( $id, true );
$all_posts = $wpdb->get_results( "SELECT ID, post_type from {$wpdb->posts}", ARRAY_A );
if ( ! $all_posts ) {
return;
}
foreach ( $all_posts as $data ) {
if ( 'attachment' === $data['post_type'] ) {
wp_delete_attachment( $data['ID'], true );
} else {
wp_delete_post( $data['ID'], true );
}
}
}

View File

@ -15,6 +15,14 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
*/
public $structure = '/%year%/%monthnum%/%day%/%postname%/';
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}
public function setUp() {
parent::setUp();
@ -134,20 +142,6 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
* @since 4.1.0
*/
public static function delete_shared_fixtures() {
self::delete_user( self::$author_id );
foreach ( self::$post_ids as $pid ) {
wp_delete_post( $pid, true );
}
foreach ( self::$comment_ids as $cid ) {
wp_delete_comment( $cid, true );
}
foreach ( self::$term_ids as $tid => $tax ) {
wp_delete_term( $tid, $tax );
}
self::$author_id = null;
self::$post_ids = array();
self::$comment_ids = array();

View File

@ -61,6 +61,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
$c = self::get_called_class();
if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
self::commit_transaction();
return;
}
@ -72,8 +73,12 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
public static function tearDownAfterClass() {
parent::tearDownAfterClass();
_delete_all_data();
self::flush_cache();
$c = self::get_called_class();
if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
self::commit_transaction();
return;
}
@ -158,7 +163,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
function clean_up_global_scope() {
$_GET = array();
$_POST = array();
$this->flush_cache();
self::flush_cache();
}
/**
@ -243,7 +248,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
}
}
function flush_cache() {
static function flush_cache() {
global $wp_object_cache;
$wp_object_cache->group_ops = array();
$wp_object_cache->stats = array();
@ -445,7 +450,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
$_SERVER['REQUEST_URI'] = $req;
unset($_SERVER['PATH_INFO']);
$this->flush_cache();
self::flush_cache();
unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
$GLOBALS['wp_the_query'] = new WP_Query();
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];

View File

@ -41,17 +41,6 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
) );
}
/**
* Delete the post and comments for the tests.
*/
public static function wpTearDownAfterClass() {
foreach ( self::$comment_ids as $comment_id ) {
wp_delete_comment( $comment_id, true );
}
wp_delete_post( self::$post_id, true );
}
/**
* Verify that both the comment date and author must match for a comment to exist.
*/

View File

@ -6,10 +6,6 @@
*/
class Tests_Admin_includesFile extends WP_UnitTestCase {
function setUp() {
parent::setUp();
}
/**
* @ticket 20449
*/

View File

@ -4,10 +4,10 @@
* @group admin
*/
class Tests_Admin_includesListTable extends WP_UnitTestCase {
protected static $top;
protected static $children;
protected static $grandchildren;
protected static $post_ids;
protected static $top = array();
protected static $children = array();
protected static $grandchildren = array();
protected static $post_ids = array();
function setUp() {
parent::setUp();
@ -64,12 +64,6 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
}
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
/**
* @ticket 15459
*/

View File

@ -22,14 +22,6 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
self::$post_id = $factory->post->create();
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $id ) {
self::delete_user( $id );
}
wp_delete_post( self::$post_id, true );
}
function test__wp_translate_postdata_cap_checks_contributor() {
wp_set_current_user( self::$contributor_id );

View File

@ -26,12 +26,6 @@ class Tests_AdminBar extends WP_UnitTestCase {
self::$user_ids[] = self::$no_role_id = $factory->user->create( array( 'role' => '' ) );
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $id ) {
self::delete_user( $id );
}
}
/**
* @ticket 21117
*/

View File

@ -35,14 +35,6 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
self::$post = get_post( self::$post_id );
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $user_id ) {
self::delete_user( $user_id );
}
wp_delete_post( self::$post_id, true );
}
/**
* Set up the test fixture
*/

View File

@ -34,14 +34,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
self::$comments = array_map( 'get_comment', $comment_ids );
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post_id, true );
foreach ( self::$comments as $c ) {
wp_delete_comment( $c->ID, true );
}
}
/**
* Clear the POST actions in between requests
*/

View File

@ -35,15 +35,6 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase {
self::$no_comment_post = $factory->post->create_and_get();
}
public static function wpTearDownAfterClass() {
foreach ( self::$comment_ids as $comment_id ) {
wp_delete_comment( $comment_id, true );
}
wp_delete_post( self::$comment_post->ID, true );
wp_delete_post( self::$no_comment_post->ID, true );
}
/**
* Get comments as a privilged user (administrator)
* Expects test to pass

View File

@ -35,15 +35,6 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase {
self::$draft_post = $factory->post->create_and_get( array( 'post_status' => 'draft' ) );
}
public static function wpTearDownAfterClass() {
foreach ( self::$comment_ids as $comment_id ) {
wp_delete_comment( $comment_id, true );
}
wp_delete_post( self::$comment_post->ID, true );
wp_delete_post( self::$draft_post->ID, true );
}
public function tearDown() {
remove_filter( 'query', array( $this, '_block_comments' ) );
parent::tearDown();

View File

@ -31,12 +31,6 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase {
}
}
public static function wpTearDownAfterClass() {
foreach ( self::$term_ids as $t ) {
wp_delete_term( $t, 'post_tag' );
}
}
/**
* Test as an admin
*/

View File

@ -26,10 +26,6 @@ class Tests_Auth extends WP_UnitTestCase {
self::$wp_hasher = new PasswordHash( 8, true );
}
public static function wpTearDownAfterClass() {
self::delete_user( self::$user_id );
}
function setUp() {
parent::setUp();

View File

@ -9,13 +9,6 @@
* @group query
*/
class Tests_Canonical extends WP_Canonical_UnitTestCase {
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}
public function setUp() {
parent::setUp();

View File

@ -22,16 +22,6 @@ class Tests_Canonical_Category extends WP_Canonical_UnitTestCase {
wp_set_post_categories( self::$posts[1], self::$cats[1] );
}
public static function wpTearDownAfterClass() {
foreach ( self::$posts as $post_id ) {
wp_delete_post( $post_id, true );
}
foreach ( self::$cats as $cat ) {
wp_delete_term( $cat, 'category' );
}
}
/**
* @dataProvider data_canonical_category
*/

View File

@ -10,13 +10,6 @@ require_once dirname( dirname( __FILE__ ) ) . '/canonical.php';
class Tests_Canonical_NoRewrite extends WP_Canonical_UnitTestCase {
// These test cases are run against the test handler in WP_Canonical
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}
public function setUp() {
global $wp_rewrite;

View File

@ -6,13 +6,6 @@
* @group query
*/
class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
public static function wpSetUpBeforeClass( $factory ) {
self::generate_shared_fixtures( $factory );
}
public static function wpTearDownAfterClass() {
self::delete_shared_fixtures();
}
function setUp() {
parent::setUp();

View File

@ -25,12 +25,6 @@ class Tests_Comment extends WP_UnitTestCase {
) );
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post_id, true );
self::delete_user( self::$user_id );
}
function test_wp_update_comment() {
$post = self::factory()->post->create_and_get( array( 'post_title' => 'some-post', 'post_type' => 'post' ) );
$post2 = self::factory()->post->create_and_get( array( 'post_title' => 'some-post-2', 'post_type' => 'post' ) );

View File

@ -28,10 +28,6 @@ class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
) );
}
public static function wpTearDownAfterClass() {
wp_delete_comment( self::$comment->comment_ID, true );
}
public function test_global_comment_with_default_parameters() {
$expected = '<a href="mailto:foo@example.org">foo@example.org</a>';

View File

@ -13,12 +13,6 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
self::$comments = array_map( 'get_comment', $comment_ids );
}
public static function wpTearDownAfterClass() {
foreach ( self::$comments as $comment ) {
wp_delete_comment( $comment, true );
}
}
protected function parseCommentAuthorUrl( $comment, $linktext = '' ) {
if ( empty( $linktext ) ) {
$linktext = rtrim( preg_replace( '#http://(www\.)?#', '', $comment->comment_author_url ), '/' );

View File

@ -44,14 +44,6 @@ class Tests_Comment_GetCommentLink extends WP_UnitTestCase {
}
public static function wpTearDownAfterClass() {
foreach ( self::$comments as $c ) {
wp_delete_comment( $c, true );
}
wp_delete_post( self::$p, true );
}
/**
* @ticket 34068
*/

View File

@ -13,10 +13,6 @@ class Tests_Comment_Query extends WP_UnitTestCase {
self::$post_id = $factory->post->create();
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post_id, true );
}
function setUp() {
parent::setUp();
}

View File

@ -22,11 +22,6 @@ class Tests_Term_WpComment extends WP_UnitTestCase {
self::$comment_id = self::factory()->comment->create();
}
public static function wpTearDownAfterClass() {
wp_delete_comment( 1, true );
wp_delete_comment( self::$comment_id, true );
}
/**
* @ticket 37738
*/

View File

@ -13,12 +13,6 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $id ) {
self::delete_user( $id );
}
}
/**
* @var WP_Customize_Manager
*/

View File

@ -44,22 +44,6 @@ class Tests_Feeds_Atom extends WP_UnitTestCase {
}
/**
* Destroy the user we created and related posts.
*/
public static function wpTearDownAfterClass() {
// Delete our user
self::delete_user( self::$user_id );
// Delete all of our posts
foreach ( self::$posts as $post ) {
wp_delete_post( $post, true );
}
// Delete our taxonomy
wp_delete_category( self::$category->term_id );
}
/**
* Setup.
*/

View File

@ -43,22 +43,6 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase {
}
}
/**
* Destroy the user we created and related posts.
*/
public static function wpTearDownAfterClass() {
// Delete our user
self::delete_user( self::$user_id );
// Delete all of our posts
foreach ( self::$posts as $post ) {
wp_delete_post( $post, true );
}
// Delete our taxonomy
wp_delete_category( self::$category->term_id );
}
/**
* Setup.
*/

View File

@ -23,12 +23,6 @@ class Tests_Get_Archives extends WP_UnitTestCase {
self::$post_ids = $factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
function test_wp_get_archives_default() {
$expected['default'] = "<li><a href='" . $this->month_url . "'>" . date( 'F Y' ) . "</a></li>";
$this->assertEquals( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) );

View File

@ -14,10 +14,6 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase {
) );
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post_id, true );
}
/**
* Test for a non existing post.
*/

View File

@ -17,8 +17,6 @@ class Tests_Media extends WP_UnitTestCase {
}
public static function wpTearDownAfterClass() {
wp_delete_attachment( self::$large_id );
$GLOBALS['_wp_additional_image_sizes'] = self::$_sizes;
}

View File

@ -9,10 +9,6 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase {
self::$post_id = $factory->post->create();
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post_id, true );
}
public function _old_sanitize_meta_cb( $meta_value, $meta_key, $meta_type ) {
return $meta_key . ' old sanitized';
}

View File

@ -16,12 +16,6 @@ class Tests_Meta_Slashes extends WP_UnitTestCase {
self::$comment_id = $factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
}
public static function wpTearDownAfterClass() {
self::delete_user( self::$editor_id );
wp_delete_comment( self::$comment_id, true );
wp_delete_post( self::$post_id, true );
}
function setUp() {
parent::setUp();

View File

@ -23,10 +23,6 @@ class Tests_Post extends WP_UnitTestCase {
}
public static function wpTearDownAfterClass() {
$ids = array( self::$editor_id, self::$grammarian_id );
foreach ( $ids as $id ) {
self::delete_user( $id );
}
remove_role( 'grammarian' );
}

View File

@ -15,13 +15,6 @@ class Tests_Post_Revisions extends WP_UnitTestCase {
self::$author_user_id = $factory->user->create( array( 'role' => 'author' ) );
}
public static function wpTearDownAfterClass() {
$ids = array( self::$admin_user_id, self::$editor_user_id, self::$author_user_id );
foreach ( $ids as $id ) {
self::delete_user( $id );
}
}
function setUp() {
parent::setUp();
$this->post_type = rand_str( 20 );

View File

@ -16,11 +16,6 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase {
) );
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$post->ID, true );
wp_delete_attachment( self::$attachment_id, true );
}
function test_has_post_thumbnail() {
$this->assertFalse( has_post_thumbnail( self::$post ) );
$this->assertFalse( has_post_thumbnail( self::$post->ID ) );

View File

@ -20,11 +20,6 @@ class Tests_Post_WpPost extends WP_UnitTestCase {
self::$post_id = self::factory()->post->create();
}
public static function wpTearDownAfterClass() {
wp_delete_post( 1, true );
wp_delete_post( self::$post_id, true );
}
/**
* @ticket 37738
*/

View File

@ -45,12 +45,6 @@ class Tests_Query_Date extends WP_UnitTestCase {
}
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
public function setUp() {
parent::setUp();
unset( $this->q );

View File

@ -25,18 +25,6 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
_unregister_post_status( 'privatefoo' );
}
public static function wpTearDownAfterClass() {
$ids = array( self::$editor_user_id, self::$author_user_id );
foreach ( $ids as $id ) {
self::delete_user( $id );
}
wp_delete_post( self::$editor_private_post, true );
wp_delete_post( self::$author_private_post, true );
wp_delete_post( self::$editor_privatefoo_post, true );
wp_delete_post( self::$author_privatefoo_post, true );
}
public function test_any_should_not_include_statuses_where_exclude_from_search_is_true() {
register_post_status( 'foo', array( 'exclude_from_search' => true ) );

View File

@ -67,20 +67,6 @@ class Tests_Query_Results extends WP_UnitTestCase {
self::$post_ids[] = self::$child_four = $factory->post->create( array( 'post_title' => 'child-four', 'post_parent' => self::$parent_two, 'post_date' => '2007-01-01 00:00:04' ) );
}
public static function wpTearDownAfterClass() {
foreach ( self::$cat_ids as $cat_id ) {
wp_delete_term( $cat_id, 'category' );
}
foreach ( self::$tag_ids as $tag_id ) {
wp_delete_term( $tag_id, 'post_tag' );
}
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
function setUp() {
parent::setUp();

View File

@ -23,12 +23,6 @@ class Tests_Query_Stickies extends WP_UnitTestCase {
stick_post( self::$posts[8] );
}
public static function wpTearDownAfterClass() {
foreach ( self::$posts as $p ) {
wp_delete_post( $p, true );
}
}
public function test_stickies_should_be_ignored_when_is_home_is_false() {
$q = new WP_Query( array(
'year' => date( 'Y' ),

View File

@ -15,11 +15,6 @@ class Tests_Rewrite_AddRewriteEndpoint extends WP_UnitTestCase {
self::$test_post_id = $factory->post->create();
}
public static function wpTearDownAfterClass() {
wp_delete_post( self::$test_page_id, true );
wp_delete_post( self::$test_post_id, true );
}
public function setUp() {
parent::setUp();

View File

@ -11,12 +11,6 @@ class Tests_Term extends WP_UnitTestCase {
self::$post_ids = $factory->post->create_many( 5 );
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
/**
* @ticket 29911
*/

View File

@ -11,12 +11,6 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase {
self::$post_ids = $factory->post->create_many( 5 );
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
/**
* @ticket 22560
*/

View File

@ -11,12 +11,6 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase {
self::$post_ids = $factory->post->create_many( 5 );
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
/**
* @ticket 26570
*/

View File

@ -33,11 +33,6 @@ class Tests_Term_WpTerm extends WP_UnitTestCase {
self::$term_id = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
}
public static function wpTearDownAfterClass() {
wp_delete_term( 1, 'wptests_tax' );
wp_delete_term( self::$term_id, 'wptests_tax' );
}
/**
* @ticket 37738
*/

View File

@ -46,12 +46,6 @@ class Tests_User extends WP_UnitTestCase {
self::$_author = get_user_by( 'ID', self::$author_id );
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $id ) {
self::delete_user( $id );
}
}
function setUp() {
parent::setUp();

View File

@ -20,12 +20,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
);
}
public static function wpTearDownAfterClass() {
foreach ( self::$users as $role => $user ) {
self::delete_user( $user->ID );
}
}
function setUp() {
parent::setUp();
// keep track of users we create
@ -1191,7 +1185,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
foreach ( $caps as $cap => $roles ) {
$this->assertFalse( current_user_can( $cap ), "Non-logged-in user should not have the {$cap} capability" );
}
}
}

View File

@ -27,21 +27,13 @@ class Tests_User_CountUserPosts extends WP_UnitTestCase {
'post_author' => 12345,
'post_type' => 'wptests_pt',
) ) );
self::$post_ids[] = $factory->post->create( array(
'post_author' => 12345,
'post_type' => 'wptests_pt',
) );
}
public static function wpTearDownAfterClass() {
self::delete_user( self::$user_id );
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
public function setUp() {
parent::setUp();
register_post_type( 'wptests_pt' );

View File

@ -40,18 +40,6 @@ class Tests_User_ListAuthors extends WP_UnitTestCase {
}
}
public static function wpTearDownAfterClass() {
self::$user_ids[] = self::$fred_id;
foreach ( self::$user_ids as $user_id ) {
self::delete_user( $user_id );
}
foreach ( self::$posts as $post_id ) {
wp_delete_post( $post_id, true );
}
}
function test_wp_list_authors_default() {
$expected['default'] = '<li><a href="' . self::$user_urls[1] . '" title="Posts by bob">bob</a></li><li><a href="' . self::$user_urls[2] . '" title="Posts by paul">paul</a></li><li><a href="' . self::$user_urls[0] . '" title="Posts by zack">zack</a></li>';
$this->AssertEquals( $expected['default'], wp_list_authors( array( 'echo' => false ) ) );

View File

@ -35,22 +35,6 @@ class Tests_User_Query extends WP_UnitTestCase {
) );
}
public static function wpTearDownAfterClass() {
$sets = array(
self::$author_ids,
self::$sub_ids,
self::$editor_ids,
array( self::$contrib_id ),
self::$admin_ids
);
foreach ( $sets as $set ) {
foreach ( $set as $id ) {
self::delete_user( $id );
}
}
}
function test_get_and_set() {
$users = new WP_User_Query();

View File

@ -13,12 +13,6 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase {
self::$user_ids[] = self::$user_id2 = $factory->user->create( array( 'user_login' => 'foo', ) );
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $id ) {
self::delete_user( $id );
}
}
public function test_set_by_id() {
$user = wp_set_current_user( self::$user_id );