Skip to:
Content

BuddyPress.org

Changeset 7041


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

Put grant_super_admin() and restore_super_admins() methods in testcase

These are useful wrapper functions for setting/unsetting super admins multiple
times during tests

Location:
trunk/tests
Files:
2 edited

Legend:

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

    r7040 r7041  
    165165                return $user_id;
    166166        }
     167
     168        /**
     169         * We can't use grant_super_admin() because we will need to modify
     170         * the list more than once, and grant_super_admin() can only be run
     171         * once because of its global check
     172         */
     173        public function grant_super_admin( $user_id ) {
     174                global $super_admins;
     175                if ( ! is_multisite() ) {
     176                        return;
     177                }
     178
     179                $user = get_userdata( $user_id );
     180                $super_admins[] = $user->user_login;
     181        }
     182
     183        public function restore_admins() {
     184                // We assume that the global can be wiped out
     185                // @see grant_super_admin()
     186                unset( $GLOBALS['super_admins'] );
     187        }
     188
     189
    167190}
  • trunk/tests/testcases/members/functions.php

    r7034 r7041  
    1616                parent::tearDown();
    1717                $this->set_current_user( $this->old_current_user );
    18         }
    19 
    20         /**
    21          * We can't use grant_super_admin() because we will need to modify
    22          * the list more than once, and grant_super_admin() can only be run
    23          * once because of its global check
    24          */
    25         public function grant_super_admin( $user_id ) {
    26                 global $super_admins;
    27                 if ( ! is_multisite() ) {
    28                         return;
    29                 }
    30 
    31                 $user = get_userdata( $user_id );
    32                 $super_admins[] = $user->user_login;
    33         }
    34 
    35         public function restore_admins() {
    36                 // We assume that the global can be wiped out
    37                 // @see grant_super_admin()
    38                 unset( $GLOBALS['super_admins'] );
    3918        }
    4019
Note: See TracChangeset for help on using the changeset viewer.