Make WordPress Core


Ignore:
Timestamp:
03/25/2014 12:13:40 PM (10 years ago)
Author:
nacin
Message:

Multisite: Don't set the $super_admins global in grant_super_admin(), revoke_super_admin().

Adds tests and docs.

props jdgrimes.
see #27205.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ms.php

    r27359 r27706  
    13011301        $this->assertQueryTrue( 'is_author', 'is_archive' );
    13021302    }
     1303
     1304    /**
     1305     * @ticket 27205
     1306     */
     1307    function test_granting_super_admins() {
     1308        if ( isset( $GLOBALS['super_admins'] ) ) {
     1309            $old_global = $GLOBALS['super_admins'];
     1310            unset( $GLOBALS['super_admins'] );
     1311        }
     1312
     1313        $user_id = $this->factory->user->create();
     1314
     1315        $this->assertFalse( is_super_admin( $user_id ) );
     1316        $this->assertFalse( revoke_super_admin( $user_id ) );
     1317        $this->assertTrue( grant_super_admin( $user_id ) );
     1318        $this->assertTrue( is_super_admin( $user_id ) );
     1319        $this->assertFalse( grant_super_admin( $user_id ) );
     1320        $this->assertTrue( revoke_super_admin( $user_id ) );
     1321
     1322        // None of these operations should set the $super_admins global.
     1323        $this->assertFalse( isset( $GLOBALS['super_admins'] ) );
     1324
     1325        // Try with two users.
     1326        $second_user = $this->factory->user->create();
     1327        $this->assertTrue( grant_super_admin( $user_id ) );
     1328        $this->assertTrue( grant_super_admin( $second_user ) );
     1329        $this->assertTrue( is_super_admin( $second_user ) );
     1330        $this->assertTrue( is_super_admin( $user_id ) );
     1331        $this->assertTrue( revoke_super_admin( $user_id ) );
     1332        $this->assertTrue( revoke_super_admin( $second_user ) );
     1333
     1334        if ( isset( $old_global ) ) {
     1335            $GLOBALS['super_admins'] = $old_global;
     1336        }
     1337    }
    13031338}
    13041339
Note: See TracChangeset for help on using the changeset viewer.