Make WordPress Core


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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();
Note: See TracChangeset for help on using the changeset viewer.