Skip to:
Content

BuddyPress.org

Changeset 7043


Ignore:
Timestamp:
05/09/2013 01:20:11 PM (11 years ago)
Author:
boonebgorges
Message:

Remove all users at the beginning of each testcase round

There's an oddity when running the test suite on multisite that causes user
1 not to be rolled back properly between tests. This messes up the unit test
sequence generator for usernames, because attempts to create new users through
the factory use duplicate user_login values. By wiping the users table at the
beginning of each test set, we ensure we're starting with a clean slate.

This is not an ideal solution - it may be a bug in the WP test suite - but it's
a harmless enough hack to get our own tests working properly for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/includes/testcase.php

    r7041 r7043  
    1313    public function setUp() {
    1414        parent::setUp();
     15
     16        // Make sure all users are deleted
     17        // There's a bug in the multisite tests that causes the
     18        // transaction rollback to fail for the first user created,
     19        // which busts every other attempt to create users. This is a
     20        // hack workaround
     21        global $wpdb;
     22        $wpdb->query( "TRUNCATE TABLE {$wpdb->users}" );
     23
    1524        $this->factory = new BP_UnitTest_Factory;
    1625    }
     
    8998
    9099        // For BuddyPress, James.
     100        $GLOBALS['bp']->loggedin_user = NULL;
    91101        do_action( 'bp_init' );
    92102    }
Note: See TracChangeset for help on using the changeset viewer.