Skip to:
Content

BuddyPress.org

Changeset 9138


Ignore:
Timestamp:
11/13/2014 04:08:51 AM (12 years ago)
Author:
boonebgorges
Message:

Delete users more selectively between tests.

In [7043] a workaround was introduced for a bug in the multisite tests. The
bug is that the admin user was not properly cleared after each test; the
workaround was to truncate the users table during setUp(). But this makes it
impossible to share user fixtures between tests. So in this changeset we
institute a narrower workaround that only deletes the specific problematic
user.

File:
1 edited

Legend:

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

    r9093 r9138  
    1717                parent::setUp();
    1818
    19                 // Make sure all users are deleted
    2019                // There's a bug in the multisite tests that causes the
    2120                // transaction rollback to fail for the first user created,
    2221                // which busts every other attempt to create users. This is a
    23                 // hack workaround
     22                // hack workaround.
    2423                global $wpdb;
    25                 $wpdb->query( "TRUNCATE TABLE {$wpdb->users}" );
     24                if ( is_multisite() ) {
     25                        $user_1 = get_user_by( 'login', 'user 1' );
     26                        if ( $user_1 ) {
     27                                $wpdb->delete( $wpdb->users, array( 'ID' => $user_1->ID ) );
     28                                clean_user_cache( $user_1 );
     29                        }
     30                }
    2631
    2732                // Fake WP mail globals, to avoid errors
Note: See TracChangeset for help on using the changeset viewer.