Make WordPress Core


Ignore:
Timestamp:
10/30/2016 12:32:03 AM (8 years ago)
Author:
johnbillion
Message:

Role/Capability: Reuse a fixture in a couple more unit tests.

See #30017

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/capabilities.php

    r38938 r39008  
    13831383        }
    13841384
    1385         $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     1385        $user = self::$users['administrator'];
    13861386        $user->add_cap( 'manage_network_users' );
    13871387        $other_user = self::$users['subscriber'];
     
    13891389        wp_set_current_user( $user->ID );
    13901390
    1391         $this->assertTrue( current_user_can( 'edit_user', $other_user->ID ) );
     1391        $can_edit_user = current_user_can( 'edit_user', $other_user->ID );
     1392
     1393        $user->remove_cap( 'manage_network_users' );
     1394
     1395        $this->assertTrue( $can_edit_user );
    13921396    }
    13931397
     
    13981402        }
    13991403
    1400         $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     1404        $user = self::$users['administrator'];
    14011405        $user->add_cap( 'manage_network_users' );
    1402         $super_admin = new WP_User( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
     1406        $super_admin = self::$users['subscriber'];
    14031407        grant_super_admin( $super_admin->ID );
    14041408
    14051409        wp_set_current_user( $user->ID );
    14061410
    1407         $this->assertFalse( current_user_can( 'edit_user', $super_admin->ID ) );
     1411        $can_edit_user = current_user_can( 'edit_user', $super_admin->ID );
     1412
     1413        $user->remove_cap( 'manage_network_users' );
     1414        revoke_super_admin( $super_admin->ID );
     1415
     1416        $this->assertFalse( $can_edit_user );
    14081417    }
    14091418
Note: See TracChangeset for help on using the changeset viewer.