Changeset 38731
- Timestamp:
- 10/05/2016 04:56:32 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r38698 r38731 975 975 */ 976 976 function test_create_posts_caps() { 977 $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); 978 $admin = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 979 $author_2 = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) ); 980 $editor = new WP_User( self::factory()->user->create( array( 'role' => 'editor' ) ) ); 981 $contributor = new WP_User( self::factory()->user->create( array( 'role' => 'contributor' ) ) ); 977 $admin = self::$users['administrator']; 978 $author = self::$users['author']; 979 $editor = self::$users['editor']; 980 $contributor = self::$users['contributor']; 982 981 983 982 // create_posts isn't a real cap. … … 985 984 $this->assertFalse($author->has_cap('create_posts')); 986 985 $this->assertFalse($editor->has_cap('create_posts')); 987 $this->assertFalse($author_2->has_cap('create_posts'));988 986 $this->assertFalse($contributor->has_cap('create_posts')); 989 987 … … 992 990 993 991 $this->assertEquals( 'edit_posts', $cap->create_posts ); 994 995 $this->assertTrue($admin->has_cap( $cap->create_posts ));996 992 997 993 $this->assertTrue($admin->has_cap( $cap->create_posts )); 998 994 $this->assertTrue($author->has_cap( $cap->create_posts )); 999 995 $this->assertTrue($editor->has_cap( $cap->create_posts )); 1000 $this->assertTrue($author_2->has_cap( $cap->create_posts ));1001 996 $this->assertTrue($contributor->has_cap( $cap->create_posts )); 1002 997 … … 1012 1007 $this->assertFalse($author->has_cap( $cap->create_posts )); 1013 1008 $this->assertFalse($editor->has_cap( $cap->create_posts )); 1014 $this->assertFalse($author_2->has_cap( $cap->create_posts ));1015 1009 $this->assertFalse($contributor->has_cap( $cap->create_posts )); 1016 1010 … … 1021 1015 $this->assertFalse($author->has_cap( $cap->create_posts )); 1022 1016 $this->assertFalse($editor->has_cap( $cap->create_posts )); 1023 $this->assertFalse($author_2->has_cap( $cap->create_posts ));1024 1017 $this->assertFalse($contributor->has_cap( $cap->create_posts )); 1018 1019 $admin->remove_cap( 'edit_foobars' ); 1025 1020 1026 1021 _unregister_post_type( 'foobar' ); … … 1201 1196 */ 1202 1197 function test_negative_caps() { 1203 $author = new WP_User( self::factory()->user->create( array( 'role' => 'author' ) ) );1198 $author = self::$users['author']; 1204 1199 $author->add_cap( 'foo', false ); 1205 1200 $this->assertTrue ( isset( $author->caps['foo'] ) ); … … 1212 1207 */ 1213 1208 function test_set_role_same_role() { 1214 $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );1209 $user = self::$users['administrator']; 1215 1210 $caps = $user->caps; 1216 1211 $this->assertNotEmpty( $user->caps ); … … 1223 1218 global $wpdb; 1224 1219 1225 $user = new WP_User( self::factory()->user->create( array( 'role' => 'administrator' ) ) );1220 $user = self::$users['administrator']; 1226 1221 $old_uid = get_current_user_id(); 1227 1222 wp_set_current_user( $user->ID );
Note: See TracChangeset
for help on using the changeset viewer.