Make WordPress Core

Changeset 38398


Ignore:
Timestamp:
08/27/2016 08:35:16 AM (8 years ago)
Author:
wonderboymusic
Message:

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 TestCases, not just those that implement wpSetUpBeforeClass and wpTearDownAfterClass
  • The tests run 10-20 seconds faster now

See #37699.

Location:
trunk/tests/phpunit
Files:
51 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/functions.php

    r38285 r38398  
    4949}
    5050
     51function _delete_all_data() {
     52    global $wpdb;
     53
     54    foreach ( array(
     55        $wpdb->posts,
     56        $wpdb->postmeta,
     57        $wpdb->comments,
     58        $wpdb->commentmeta,
     59        $wpdb->term_relationships,
     60        $wpdb->termmeta
     61    ) as $table ) {
     62        $wpdb->query( "DELETE FROM {$table}" );
     63    }
     64
     65    foreach ( array(
     66        $wpdb->terms,
     67        $wpdb->term_taxonomy
     68    ) as $table ) {
     69        $wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" );
     70    }
     71
     72    $wpdb->query( "UPDATE {$wpdb->term_taxonomy} SET count = 0" );
     73
     74    $wpdb->query( "DELETE FROM {$wpdb->users} WHERE ID != 1" );
     75    $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id != 1" );
     76}
     77
    5178function _delete_all_posts() {
    5279    global $wpdb;
    5380
    54     $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}");
    55     if ($all_posts) {
    56         foreach ($all_posts as $id)
    57             wp_delete_post( $id, true );
     81    $all_posts = $wpdb->get_results( "SELECT ID, post_type from {$wpdb->posts}", ARRAY_A );
     82    if ( ! $all_posts ) {
     83        return;
     84    }
     85
     86    foreach ( $all_posts as $data ) {
     87        if ( 'attachment' === $data['post_type'] ) {
     88            wp_delete_attachment( $data['ID'], true );
     89        } else {
     90            wp_delete_post( $data['ID'], true );
     91        }
    5892    }
    5993}
  • trunk/tests/phpunit/includes/testcase-canonical.php

    r36236 r38398  
    1616    public $structure = '/%year%/%monthnum%/%day%/%postname%/';
    1717
     18    public static function wpSetUpBeforeClass( $factory ) {
     19        self::generate_shared_fixtures( $factory );
     20    }
     21
     22    public static function wpTearDownAfterClass() {
     23        self::delete_shared_fixtures();
     24    }
     25
    1826    public function setUp() {
    1927        parent::setUp();
     
    135143     */
    136144    public static function delete_shared_fixtures() {
    137         self::delete_user( self::$author_id );
    138 
    139         foreach ( self::$post_ids as $pid ) {
    140             wp_delete_post( $pid, true );
    141         }
    142 
    143         foreach ( self::$comment_ids as $cid ) {
    144             wp_delete_comment( $cid, true );
    145         }
    146 
    147         foreach ( self::$term_ids as $tid => $tax ) {
    148             wp_delete_term( $tid, $tax );
    149         }
    150 
    151145        self::$author_id = null;
    152146        self::$post_ids = array();
  • trunk/tests/phpunit/includes/testcase.php

    r37861 r38398  
    6262        $c = self::get_called_class();
    6363        if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) {
     64            self::commit_transaction();
    6465            return;
    6566        }
     
    7374        parent::tearDownAfterClass();
    7475
     76        _delete_all_data();
     77        self::flush_cache();
     78
    7579        $c = self::get_called_class();
    7680        if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) {
     81            self::commit_transaction();
    7782            return;
    7883        }
     
    159164        $_GET = array();
    160165        $_POST = array();
    161         $this->flush_cache();
     166        self::flush_cache();
    162167    }
    163168
     
    244249    }
    245250
    246     function flush_cache() {
     251    static function flush_cache() {
    247252        global $wp_object_cache;
    248253        $wp_object_cache->group_ops = array();
     
    446451        unset($_SERVER['PATH_INFO']);
    447452
    448         $this->flush_cache();
     453        self::flush_cache();
    449454        unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
    450455        $GLOBALS['wp_the_query'] = new WP_Query();
  • trunk/tests/phpunit/tests/admin/includesComment.php

    r38372 r38398  
    4343
    4444    /**
    45      * Delete the post and comments for the tests.
    46      */
    47     public static function wpTearDownAfterClass() {
    48         foreach ( self::$comment_ids as $comment_id ) {
    49             wp_delete_comment( $comment_id, true );
    50         }
    51 
    52         wp_delete_post( self::$post_id, true );
    53     }
    54 
    55     /**
    5645     * Verify that both the comment date and author must match for a comment to exist.
    5746     */
  • trunk/tests/phpunit/tests/admin/includesFile.php

    r25002 r38398  
    66 */
    77class Tests_Admin_includesFile extends WP_UnitTestCase {
    8 
    9     function setUp() {
    10         parent::setUp();
    11     }
    128
    139    /**
  • trunk/tests/phpunit/tests/admin/includesListTable.php

    r35186 r38398  
    55 */
    66class Tests_Admin_includesListTable extends WP_UnitTestCase {
    7     protected static $top;
    8     protected static $children;
    9     protected static $grandchildren;
    10     protected static $post_ids;
     7    protected static $top = array();
     8    protected static $children = array();
     9    protected static $grandchildren = array();
     10    protected static $post_ids = array();
    1111
    1212    function setUp() {
     
    6262                }
    6363            }
    64         }
    65     }
    66 
    67     public static function wpTearDownAfterClass() {
    68         foreach ( self::$post_ids as $post_id ) {
    69             wp_delete_post( $post_id, true );
    7064        }
    7165    }
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r37914 r38398  
    2121
    2222        self::$post_id = $factory->post->create();
    23     }
    24 
    25     public static function wpTearDownAfterClass() {
    26         foreach ( self::$user_ids as $id ) {
    27             self::delete_user( $id );
    28         }
    29 
    30         wp_delete_post( self::$post_id, true );
    3123    }
    3224
  • trunk/tests/phpunit/tests/adminbar.php

    r38035 r38398  
    2727    }
    2828
    29     public static function wpTearDownAfterClass() {
    30         foreach ( self::$user_ids as $id ) {
    31             self::delete_user( $id );
    32         }
    33     }
    34 
    3529    /**
    3630     * @ticket 21117
  • trunk/tests/phpunit/tests/ajax/Autosave.php

    r35311 r38398  
    3434        self::$post_id = $factory->post->create( array( 'post_status' => 'draft' ) );
    3535        self::$post = get_post( self::$post_id );
    36     }
    37 
    38     public static function wpTearDownAfterClass() {
    39         foreach ( self::$user_ids as $user_id ) {
    40             self::delete_user( $user_id );
    41         }
    42 
    43         wp_delete_post( self::$post_id, true );
    4436    }
    4537
  • trunk/tests/phpunit/tests/ajax/DeleteComment.php

    r37404 r38398  
    3535    }
    3636
    37     public static function wpTearDownAfterClass() {
    38         wp_delete_post( self::$post_id, true );
    39 
    40         foreach ( self::$comments as $c ) {
    41             wp_delete_comment( $c->ID, true );
    42         }
    43     }
    44 
    4537    /**
    4638     * Clear the POST actions in between requests
  • trunk/tests/phpunit/tests/ajax/GetComments.php

    r35311 r38398  
    3434        self::$comment_ids = $factory->comment->create_post_comments( self::$comment_post->ID, 5 );
    3535        self::$no_comment_post = $factory->post->create_and_get();
    36     }
    37 
    38     public static function wpTearDownAfterClass() {
    39         foreach ( self::$comment_ids as $comment_id ) {
    40             wp_delete_comment( $comment_id, true );
    41         }
    42 
    43         wp_delete_post( self::$comment_post->ID, true );
    44         wp_delete_post( self::$no_comment_post->ID, true );
    4536    }
    4637
  • trunk/tests/phpunit/tests/ajax/ReplytoComment.php

    r35311 r38398  
    3636    }
    3737
    38     public static function wpTearDownAfterClass() {
    39         foreach ( self::$comment_ids as $comment_id ) {
    40             wp_delete_comment( $comment_id, true );
    41         }
    42 
    43         wp_delete_post( self::$comment_post->ID, true );
    44         wp_delete_post( self::$draft_post->ID, true );
    45     }
    46 
    4738    public function tearDown() {
    4839        remove_filter( 'query', array( $this, '_block_comments' ) );
  • trunk/tests/phpunit/tests/ajax/TagSearch.php

    r35311 r38398  
    2929        foreach ( self::$terms as $t ) {
    3030            self::$term_ids[] = wp_insert_term( $t, 'post_tag' );
    31         }
    32     }
    33 
    34     public static function wpTearDownAfterClass() {
    35         foreach ( self::$term_ids as $t ) {
    36             wp_delete_term( $t, 'post_tag' );
    3731        }
    3832    }
  • trunk/tests/phpunit/tests/auth.php

    r36617 r38398  
    2727    }
    2828
    29     public static function wpTearDownAfterClass() {
    30         self::delete_user( self::$user_id );
    31     }
    32 
    3329    function setUp() {
    3430        parent::setUp();
  • trunk/tests/phpunit/tests/canonical.php

    r38063 r38398  
    1010 */
    1111class Tests_Canonical extends WP_Canonical_UnitTestCase {
    12     public static function wpSetUpBeforeClass( $factory ) {
    13         self::generate_shared_fixtures( $factory );
    14     }
    15 
    16     public static function wpTearDownAfterClass() {
    17         self::delete_shared_fixtures();
    18     }
    1912
    2013    public function setUp() {
  • trunk/tests/phpunit/tests/canonical/category.php

    r38216 r38398  
    2121        wp_set_post_categories( self::$posts[0], self::$cats[0] );
    2222        wp_set_post_categories( self::$posts[1], self::$cats[1] );
    23     }
    24 
    25     public static function wpTearDownAfterClass() {
    26         foreach ( self::$posts as $post_id ) {
    27             wp_delete_post( $post_id, true );
    28         }
    29 
    30         foreach ( self::$cats as $cat ) {
    31             wp_delete_term( $cat, 'category' );
    32         }
    3323    }
    3424
  • trunk/tests/phpunit/tests/canonical/noRewrite.php

    r35191 r38398  
    1111
    1212    // These test cases are run against the test handler in WP_Canonical
    13     public static function wpSetUpBeforeClass( $factory ) {
    14         self::generate_shared_fixtures( $factory );
    15     }
    16 
    17     public static function wpTearDownAfterClass() {
    18         self::delete_shared_fixtures();
    19     }
    2013
    2114    public function setUp() {
  • trunk/tests/phpunit/tests/canonical/pageOnFront.php

    r36238 r38398  
    77 */
    88class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
    9     public static function wpSetUpBeforeClass( $factory ) {
    10         self::generate_shared_fixtures( $factory );
    11     }
    12 
    13     public static function wpTearDownAfterClass() {
    14         self::delete_shared_fixtures();
    15     }
    169
    1710    function setUp() {
  • trunk/tests/phpunit/tests/comment.php

    r37954 r38398  
    2424            'post_author' => self::$user_id
    2525        ) );
    26     }
    27 
    28     public static function wpTearDownAfterClass() {
    29         wp_delete_post( self::$post_id, true );
    30 
    31         self::delete_user( self::$user_id );
    3226    }
    3327
  • trunk/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php

    r37348 r38398  
    2727            'comment_author_email' => 'foo@example.org'
    2828        ) );
    29     }
    30 
    31     public static function wpTearDownAfterClass() {
    32         wp_delete_comment( self::$comment->comment_ID, true );
    3329    }
    3430
  • trunk/tests/phpunit/tests/comment/getCommentAuthorUrlLink.php

    r37305 r38398  
    1212        $comment_ids = $factory->comment->create_post_comments( 0, 1 );
    1313        self::$comments = array_map( 'get_comment', $comment_ids );
    14     }
    15 
    16     public static function wpTearDownAfterClass() {
    17         foreach ( self::$comments as $comment ) {
    18             wp_delete_comment( $comment, true );
    19         }
    2014    }
    2115
  • trunk/tests/phpunit/tests/comment/getCommentLink.php

    r35933 r38398  
    4343        ) );
    4444
    45     }
    46 
    47     public static function wpTearDownAfterClass() {
    48         foreach ( self::$comments as $c ) {
    49             wp_delete_comment( $c, true );
    50         }
    51 
    52         wp_delete_post( self::$p, true );
    5345    }
    5446
  • trunk/tests/phpunit/tests/comment/query.php

    r38001 r38398  
    1212    public static function wpSetUpBeforeClass( $factory ) {
    1313        self::$post_id = $factory->post->create();
    14     }
    15 
    16     public static function wpTearDownAfterClass() {
    17         wp_delete_post( self::$post_id, true );
    1814    }
    1915
  • trunk/tests/phpunit/tests/comment/wpComment.php

    r38381 r38398  
    2121
    2222        self::$comment_id = self::factory()->comment->create();
    23     }
    24 
    25     public static function wpTearDownAfterClass() {
    26         wp_delete_comment( 1, true );
    27         wp_delete_comment( self::$comment_id, true );
    2823    }
    2924
  • trunk/tests/phpunit/tests/customize/section.php

    r35249 r38398  
    1212    public static function wpSetUpBeforeClass( $factory ) {
    1313        self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
    14     }
    15 
    16     public static function wpTearDownAfterClass() {
    17         foreach ( self::$user_ids as $id ) {
    18             self::delete_user( $id );
    19         }
    2014    }
    2115
  • trunk/tests/phpunit/tests/feed/atom.php

    r36519 r38398  
    4343        }
    4444
    45     }
    46 
    47     /**
    48      * Destroy the user we created and related posts.
    49      */
    50     public static function wpTearDownAfterClass() {
    51         // Delete our user
    52         self::delete_user( self::$user_id );
    53 
    54         // Delete all of our posts
    55         foreach ( self::$posts as $post ) {
    56             wp_delete_post( $post, true );
    57         }
    58 
    59         // Delete our taxonomy
    60         wp_delete_category( self::$category->term_id );
    6145    }
    6246
  • trunk/tests/phpunit/tests/feed/rss2.php

    r36519 r38398  
    4545
    4646    /**
    47      * Destroy the user we created and related posts.
    48      */
    49     public static function wpTearDownAfterClass() {
    50         // Delete our user
    51         self::delete_user( self::$user_id );
    52 
    53         // Delete all of our posts
    54         foreach ( self::$posts as $post ) {
    55             wp_delete_post( $post, true );
    56         }
    57 
    58         // Delete our taxonomy
    59         wp_delete_category( self::$category->term_id );
    60     }
    61 
    62     /**
    6347     * Setup.
    6448     */
  • trunk/tests/phpunit/tests/functions/getArchives.php

    r37271 r38398  
    2222    public static function wpSetUpBeforeClass( $factory ) {
    2323        self::$post_ids = $factory->post->create_many( 8, array( 'post_type' => 'post', 'post_author' => '1' ) );
    24     }
    25 
    26     public static function wpTearDownAfterClass() {
    27         foreach ( self::$post_ids as $post_id ) {
    28             wp_delete_post( $post_id, true );
    29         }
    3024    }
    3125
  • trunk/tests/phpunit/tests/link/wpGetCanonicalURL.php

    r37685 r38398  
    1313            'post_status' => 'publish',
    1414        ) );
    15     }
    16 
    17     public static function wpTearDownAfterClass() {
    18         wp_delete_post( self::$post_id, true );
    1915    }
    2016
  • trunk/tests/phpunit/tests/media.php

    r38383 r38398  
    1818
    1919    public static function wpTearDownAfterClass() {
    20         wp_delete_attachment( self::$large_id );
    21 
    2220        $GLOBALS['_wp_additional_image_sizes'] = self::$_sizes;
    2321    }
  • trunk/tests/phpunit/tests/meta/registerMeta.php

    r38095 r38398  
    88    public static function wpSetUpBeforeClass( $factory ) {
    99        self::$post_id = $factory->post->create();
    10     }
    11 
    12     public static function wpTearDownAfterClass() {
    13         wp_delete_post( self::$post_id, true );
    1410    }
    1511
  • trunk/tests/phpunit/tests/meta/slashes.php

    r36787 r38398  
    1515        self::$post_id = $factory->post->create();
    1616        self::$comment_id = $factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
    17     }
    18 
    19     public static function wpTearDownAfterClass() {
    20         self::delete_user( self::$editor_id );
    21         wp_delete_comment( self::$comment_id, true );
    22         wp_delete_post( self::$post_id, true );
    2317    }
    2418
  • trunk/tests/phpunit/tests/post.php

    r38143 r38398  
    2424
    2525    public static function wpTearDownAfterClass() {
    26         $ids = array( self::$editor_id, self::$grammarian_id );
    27         foreach ( $ids as $id ) {
    28             self::delete_user( $id );
    29         }
    3026        remove_role( 'grammarian' );
    3127    }
  • trunk/tests/phpunit/tests/post/revisions.php

    r36659 r38398  
    1414        self::$editor_user_id = $factory->user->create( array( 'role' => 'editor' ) );
    1515        self::$author_user_id = $factory->user->create( array( 'role' => 'author' ) );
    16     }
    17 
    18     public static function wpTearDownAfterClass() {
    19         $ids = array( self::$admin_user_id, self::$editor_user_id, self::$author_user_id );
    20         foreach ( $ids as $id ) {
    21             self::delete_user( $id );
    22         }
    2316    }
    2417
  • trunk/tests/phpunit/tests/post/thumbnails.php

    r38263 r38398  
    1717    }
    1818
    19     public static function wpTearDownAfterClass() {
    20         wp_delete_post( self::$post->ID, true );
    21         wp_delete_attachment( self::$attachment_id, true );
    22     }
    23 
    2419    function test_has_post_thumbnail() {
    2520        $this->assertFalse( has_post_thumbnail( self::$post ) );
  • trunk/tests/phpunit/tests/post/wpPost.php

    r38381 r38398  
    1919
    2020        self::$post_id = self::factory()->post->create();
    21     }
    22 
    23     public static function wpTearDownAfterClass() {
    24         wp_delete_post( 1, true );
    25         wp_delete_post( self::$post_id, true );
    2621    }
    2722
  • trunk/tests/phpunit/tests/query/date.php

    r37324 r38398  
    4646    }
    4747
    48     public static function wpTearDownAfterClass() {
    49         foreach ( self::$post_ids as $post_id ) {
    50             wp_delete_post( $post_id, true );
    51         }
    52     }
    53 
    5448    public function setUp() {
    5549        parent::setUp();
  • trunk/tests/phpunit/tests/query/postStatus.php

    r35242 r38398  
    2626    }
    2727
    28     public static function wpTearDownAfterClass() {
    29         $ids = array( self::$editor_user_id, self::$author_user_id );
    30         foreach ( $ids as $id ) {
    31             self::delete_user( $id );
    32         }
    33 
    34         wp_delete_post( self::$editor_private_post, true );
    35         wp_delete_post( self::$author_private_post, true );
    36         wp_delete_post( self::$editor_privatefoo_post, true );
    37         wp_delete_post( self::$author_privatefoo_post, true );
    38     }
    39 
    4028    public function test_any_should_not_include_statuses_where_exclude_from_search_is_true() {
    4129        register_post_status( 'foo', array( 'exclude_from_search' => true ) );
  • trunk/tests/phpunit/tests/query/results.php

    r38382 r38398  
    6868    }
    6969
    70     public static function wpTearDownAfterClass() {
    71         foreach ( self::$cat_ids as $cat_id ) {
    72             wp_delete_term( $cat_id, 'category' );
    73         }
    74 
    75         foreach ( self::$tag_ids as $tag_id ) {
    76             wp_delete_term( $tag_id, 'post_tag' );
    77         }
    78 
    79         foreach ( self::$post_ids as $post_id ) {
    80             wp_delete_post( $post_id, true );
    81         }
    82     }
    83 
    8470    function setUp() {
    8571        parent::setUp();
  • trunk/tests/phpunit/tests/query/stickies.php

    r35186 r38398  
    2222        stick_post( self::$posts[14] );
    2323        stick_post( self::$posts[8] );
    24     }
    25 
    26     public static function wpTearDownAfterClass() {
    27         foreach ( self::$posts as $p ) {
    28             wp_delete_post( $p, true );
    29         }
    3024    }
    3125
  • trunk/tests/phpunit/tests/rewrite/addRewriteEndpoint.php

    r35260 r38398  
    1414        ) );
    1515        self::$test_post_id = $factory->post->create();
    16     }
    17 
    18     public static function wpTearDownAfterClass() {
    19         wp_delete_post( self::$test_page_id, true );
    20         wp_delete_post( self::$test_post_id, true );
    2116    }
    2217
  • trunk/tests/phpunit/tests/term.php

    r37644 r38398  
    1010    public static function wpSetUpBeforeClass( $factory ) {
    1111        self::$post_ids = $factory->post->create_many( 5 );
    12     }
    13 
    14     public static function wpTearDownAfterClass() {
    15         foreach ( self::$post_ids as $post_id ) {
    16             wp_delete_post( $post_id, true );
    17         }
    1812    }
    1913
  • trunk/tests/phpunit/tests/term/getTheTerms.php

    r37573 r38398  
    1010    public static function wpSetUpBeforeClass( $factory ) {
    1111        self::$post_ids = $factory->post->create_many( 5 );
    12     }
    13 
    14     public static function wpTearDownAfterClass() {
    15         foreach ( self::$post_ids as $post_id ) {
    16             wp_delete_post( $post_id, true );
    17         }
    1812    }
    1913
  • trunk/tests/phpunit/tests/term/wpSetObjectTerms.php

    r38382 r38398  
    1010    public static function wpSetUpBeforeClass( $factory ) {
    1111        self::$post_ids = $factory->post->create_many( 5 );
    12     }
    13 
    14     public static function wpTearDownAfterClass() {
    15         foreach ( self::$post_ids as $post_id ) {
    16             wp_delete_post( $post_id, true );
    17         }
    1812    }
    1913
  • trunk/tests/phpunit/tests/term/wpTerm.php

    r38381 r38398  
    3232
    3333        self::$term_id = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    34     }
    35 
    36     public static function wpTearDownAfterClass() {
    37         wp_delete_term( 1, 'wptests_tax' );
    38         wp_delete_term( self::$term_id, 'wptests_tax' );
    3934    }
    4035
  • trunk/tests/phpunit/tests/user.php

    r38382 r38398  
    4545
    4646        self::$_author = get_user_by( 'ID', self::$author_id );
    47     }
    48 
    49     public static function wpTearDownAfterClass() {
    50         foreach ( self::$user_ids as $id ) {
    51             self::delete_user( $id );
    52         }
    5347    }
    5448
  • trunk/tests/phpunit/tests/user/capabilities.php

    r38096 r38398  
    1919            'subscriber'    => $factory->user->create_and_get( array( 'role' => 'subscriber' ) ),
    2020        );
    21     }
    22 
    23     public static function wpTearDownAfterClass() {
    24         foreach ( self::$users as $role => $user ) {
    25             self::delete_user( $user->ID );
    26         }
    2721    }
    2822
     
    11921186        foreach ( $caps as $cap => $roles ) {
    11931187            $this->assertFalse( current_user_can( $cap ), "Non-logged-in user should not have the {$cap} capability" );
    1194         }       
     1188        }
    11951189
    11961190    }
  • trunk/tests/phpunit/tests/user/countUserPosts.php

    r35244 r38398  
    2828            'post_type'   => 'wptests_pt',
    2929        ) ) );
    30        
     30
    3131        self::$post_ids[] = $factory->post->create( array(
    3232            'post_author' => 12345,
    3333            'post_type'   => 'wptests_pt',
    3434        ) );
    35     }
    36 
    37     public static function wpTearDownAfterClass() {
    38         self::delete_user( self::$user_id );
    39 
    40         foreach ( self::$post_ids as $post_id ) {
    41             wp_delete_post( $post_id, true );
    42         }
    4335    }
    4436
  • trunk/tests/phpunit/tests/user/listAuthors.php

    r35244 r38398  
    3838
    3939            self::$user_urls[] = get_author_posts_url( $userid );
    40         }
    41     }
    42 
    43     public static function wpTearDownAfterClass() {
    44         self::$user_ids[] = self::$fred_id;
    45 
    46         foreach ( self::$user_ids as $user_id ) {
    47             self::delete_user( $user_id );
    48         }
    49 
    50         foreach ( self::$posts as $post_id ) {
    51             wp_delete_post( $post_id, true );
    5240        }
    5341    }
  • trunk/tests/phpunit/tests/user/query.php

    r37360 r38398  
    3434            'role' => 'administrator',
    3535        ) );
    36     }
    37 
    38     public static function wpTearDownAfterClass() {
    39         $sets = array(
    40             self::$author_ids,
    41             self::$sub_ids,
    42             self::$editor_ids,
    43             array( self::$contrib_id ),
    44             self::$admin_ids
    45         );
    46 
    47         foreach ( $sets as $set ) {
    48             foreach ( $set as $id ) {
    49                 self::delete_user( $id );
    50             }
    51         }
    5236    }
    5337
  • trunk/tests/phpunit/tests/user/wpSetCurrentUser.php

    r35248 r38398  
    1212        self::$user_ids[] = self::$user_id = $factory->user->create();
    1313        self::$user_ids[] = self::$user_id2 = $factory->user->create( array( 'user_login' => 'foo', ) );
    14     }
    15 
    16     public static function wpTearDownAfterClass() {
    17         foreach ( self::$user_ids as $id ) {
    18             self::delete_user( $id );
    19         }
    2014    }
    2115
Note: See TracChangeset for help on using the changeset viewer.