Changeset 48937 for trunk/tests/phpunit/tests/user/capabilities.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r48788 r48937 343 343 sort( $single_primitive ); 344 344 sort( $multi_primitive ); 345 $this->assert Equals( $single_primitive, $multi_primitive );345 $this->assertSame( $single_primitive, $multi_primitive ); 346 346 347 347 $single_meta = array_keys( $this->_getSingleSiteMetaCaps() ); … … 349 349 sort( $single_meta ); 350 350 sort( $multi_meta ); 351 $this->assert Equals( $single_meta, $multi_meta );351 $this->assertSame( $single_meta, $multi_meta ); 352 352 } 353 353 … … 379 379 $diff = array_diff( array_keys( $user_caps ), array_keys( $caps ) ); 380 380 381 $this->assert Equals( array(), $diff, "User with {$role} role has capabilities that aren't being tested" );381 $this->assertSame( array(), $diff, "User with {$role} role has capabilities that aren't being tested" ); 382 382 383 383 } … … 522 522 523 523 // Make sure the role name is correct. 524 $this->assert Equals( array( $role ), $user->roles, "User should only have the {$role} role" );524 $this->assertSame( array( $role ), $user->roles, "User should only have the {$role} role" ); 525 525 526 526 foreach ( $caps as $cap => $roles ) { … … 762 762 763 763 // Make sure the role name is correct. 764 $this->assert Equals( array(), $user->roles, 'User should not have any roles' );764 $this->assertSame( array(), $user->roles, 'User should not have any roles' ); 765 765 766 766 $caps = $this->getAllCapsAndRoles(); … … 784 784 785 785 // User should have two roles now. 786 $this->assert Equals( array( 'subscriber', 'contributor' ), $user->roles );786 $this->assertSame( array( 'subscriber', 'contributor' ), $user->roles ); 787 787 788 788 $caps = $this->getAllCapsAndRoles(); … … 800 800 $user->remove_role( 'contributor' ); 801 801 // User should have one role now. 802 $this->assert Equals( array( 'subscriber' ), $user->roles );802 $this->assertSame( array( 'subscriber' ), $user->roles ); 803 803 804 804 } … … 822 822 823 823 // Make sure the role name is correct. 824 $this->assert Equals( array( $role_name ), $user->roles );824 $this->assertSame( array( $role_name ), $user->roles ); 825 825 826 826 $caps = $this->getAllCapsAndRoles(); … … 861 861 862 862 // Make sure the role name is correct. 863 $this->assert Equals( array( $role_name ), $user->roles );863 $this->assertSame( array( $role_name ), $user->roles ); 864 864 865 865 $caps = $this->getPrimitiveCapsAndRoles(); … … 902 902 $user = new WP_User( $id ); 903 903 $this->assertTrue( $user->exists(), "Problem getting user $id" ); 904 $this->assert Equals( array( $role_name ), $user->roles );904 $this->assertSame( array( $role_name ), $user->roles ); 905 905 906 906 // The user should have all the above caps. … … 952 952 $user = new WP_User( $id ); 953 953 $this->assertTrue( $user->exists(), "Problem getting user $id" ); 954 $this->assert Equals( array( $role_name ), $user->roles );954 $this->assertSame( array( $role_name ), $user->roles ); 955 955 956 956 // The user should have all the above caps. … … 989 989 990 990 // Make sure they're both still contributors. 991 $this->assert Equals( array( 'contributor' ), $user_1->roles );992 $this->assert Equals( array( 'contributor' ), $user_2->roles );991 $this->assertSame( array( 'contributor' ), $user_1->roles ); 992 $this->assertSame( array( 'contributor' ), $user_2->roles ); 993 993 994 994 // Check the extra cap on both users. … … 1031 1031 1032 1032 // Make sure they're both still contributors. 1033 $this->assert Equals( array( 'contributor' ), $user_1->roles );1034 $this->assert Equals( array( 'contributor' ), $user_2->roles );1033 $this->assertSame( array( 'contributor' ), $user_1->roles ); 1034 $this->assertSame( array( 'contributor' ), $user_2->roles ); 1035 1035 1036 1036 // Check the removed cap on both users. … … 1054 1054 // They get promoted to editor - level should get bumped to 7. 1055 1055 $user->set_role( 'editor' ); 1056 $this->assert Equals( 7, $user->user_level );1056 $this->assertSame( 7, $user->user_level ); 1057 1057 1058 1058 // Demoted to contributor - level is reduced to 1. 1059 1059 $user->set_role( 'contributor' ); 1060 $this->assert Equals( 1, $user->user_level );1060 $this->assertSame( 1, $user->user_level ); 1061 1061 1062 1062 // If they have two roles, user_level should be the max of the two. 1063 1063 $user->add_role( 'editor' ); 1064 $this->assert Equals( array( 'contributor', 'editor' ), $user->roles );1065 $this->assert Equals( 7, $user->user_level );1064 $this->assertSame( array( 'contributor', 'editor' ), $user->roles ); 1065 $this->assertSame( 7, $user->user_level ); 1066 1066 } 1067 1067 … … 1154 1154 register_post_type( 'something', array( 'capabilities' => array( 'edit_posts' => 'draw_somethings' ) ) ); 1155 1155 $something = get_post_type_object( 'something' ); 1156 $this->assert Equals( 'draw_somethings', $something->cap->edit_posts );1157 $this->assert Equals( 'draw_somethings', $something->cap->create_posts );1156 $this->assertSame( 'draw_somethings', $something->cap->edit_posts ); 1157 $this->assertSame( 'draw_somethings', $something->cap->create_posts ); 1158 1158 1159 1159 register_post_type( … … 1168 1168 ); 1169 1169 $something = get_post_type_object( 'something' ); 1170 $this->assert Equals( 'draw_somethings', $something->cap->edit_posts );1171 $this->assert Equals( 'create_somethings', $something->cap->create_posts );1170 $this->assertSame( 'draw_somethings', $something->cap->edit_posts ); 1171 $this->assertSame( 'create_somethings', $something->cap->create_posts ); 1172 1172 _unregister_post_type( 'something' ); 1173 1173 … … 1230 1230 $this->assertFalse( $contributor->has_cap( 'edit_post', $post ) ); 1231 1231 $this->assertFalse( $contributor->has_cap( 'delete_post', $post ) ); 1232 $this->assert Equals( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) );1232 $this->assertSame( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) ); 1233 1233 } 1234 1234 … … 1253 1253 $cap = get_post_type_object( 'foobar' )->cap; 1254 1254 1255 $this->assert Equals( 'edit_posts', $cap->create_posts );1255 $this->assertSame( 'edit_posts', $cap->create_posts ); 1256 1256 1257 1257 $this->assertTrue( $admin->has_cap( $cap->create_posts ) ); … … 1267 1267 $cap = get_post_type_object( 'foobar' )->cap; 1268 1268 1269 $this->assert Equals( 'edit_foobars', $cap->create_posts );1269 $this->assertSame( 'edit_foobars', $cap->create_posts ); 1270 1270 1271 1271 $this->assertFalse( $admin->has_cap( $cap->create_posts ) ); … … 1289 1289 1290 1290 $cap = get_post_type_object( 'attachment' )->cap; 1291 $this->assert Equals( 'upload_files', $cap->create_posts );1292 $this->assert Equals( 'edit_posts', $cap->edit_posts );1291 $this->assertSame( 'upload_files', $cap->create_posts ); 1292 $this->assertSame( 'edit_posts', $cap->edit_posts ); 1293 1293 1294 1294 $this->assertTrue( $author->has_cap( $cap->create_posts ) ); … … 1363 1363 foreach ( $expected as $meta_cap => $primitive_cap ) { 1364 1364 $caps = map_meta_cap( $tax->cap->$meta_cap, $user->ID ); 1365 $this->assert Equals(1365 $this->assertSame( 1366 1366 array( 1367 1367 $primitive_cap, … … 1472 1472 foreach ( $expected as $meta_cap => $primitive_cap ) { 1473 1473 $caps = map_meta_cap( $tax->cap->$meta_cap, $user->ID ); 1474 $this->assert Equals(1474 $this->assertSame( 1475 1475 array( 1476 1476 $primitive_cap, … … 1527 1527 $user->set_role( 'administrator' ); 1528 1528 $this->assertNotEmpty( $user->caps ); 1529 $this->assert Equals( $caps, $user->caps );1529 $this->assertSame( $caps, $user->caps ); 1530 1530 } 1531 1531 … … 1568 1568 current_user_can_for_blog( $blog_id, 'edit_posts' ); 1569 1569 1570 $this->assert Equals( $orig_blog_id, get_current_blog_id() );1570 $this->assertSame( $orig_blog_id, get_current_blog_id() ); 1571 1571 } 1572 1572 … … 1815 1815 $contributor = self::$users['contributor']; 1816 1816 1817 $this->assert Equals( 'edit_pages', $cpt->cap->edit_posts );1817 $this->assertSame( 'edit_pages', $cpt->cap->edit_posts ); 1818 1818 $this->assertTrue( user_can( $admin->ID, $cpt->cap->edit_posts ) ); 1819 1819 $this->assertTrue( user_can( $editor->ID, $cpt->cap->edit_posts ) ); … … 1875 1875 wp_logout(); 1876 1876 1877 $this->assert Equals( 0, get_current_user_id() );1877 $this->assertSame( 0, get_current_user_id() ); 1878 1878 1879 1879 } … … 2193 2193 function test_block_caps( $role, $cap, $use_post, $expected ) { 2194 2194 if ( $use_post ) { 2195 $this->assert Equals( $expected, self::$users[ $role ]->has_cap( $cap, self::$block_id ) );2195 $this->assertSame( $expected, self::$users[ $role ]->has_cap( $cap, self::$block_id ) ); 2196 2196 } else { 2197 $this->assert Equals( $expected, self::$users[ $role ]->has_cap( $cap ) );2197 $this->assertSame( $expected, self::$users[ $role ]->has_cap( $cap ) ); 2198 2198 } 2199 2199 }
Note: See TracChangeset
for help on using the changeset viewer.