| 1084 | /** |
| 1085 | * @ticket 31518 |
| 1086 | */ |
| 1087 | function test_no_meta_caps_results_in_no_caps() { |
| 1088 | |
| 1089 | $this->markTestIncomplete(); |
| 1090 | |
| 1091 | add_filter( 'map_meta_cap', array( $this, '_return_empty_array' ) ); |
| 1092 | |
| 1093 | $users = array( |
| 1094 | 'administrator' => $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ), |
| 1095 | 'editor' => $this->factory->user->create_and_get( array( 'role' => 'editor' ) ), |
| 1096 | 'author' => $this->factory->user->create_and_get( array( 'role' => 'author' ) ), |
| 1097 | 'contributor' => $this->factory->user->create_and_get( array( 'role' => 'contributor' ) ), |
| 1098 | 'subscriber' => $this->factory->user->create_and_get( array( 'role' => 'subscriber' ) ), |
| 1099 | ); |
| 1100 | |
| 1101 | $caps = $this->getCapsAndRoles(); |
| 1102 | |
| 1103 | foreach ( $users as $role => $user ) { |
| 1104 | |
| 1105 | // make sure the user is valid |
| 1106 | $this->assertTrue( $user->exists(), "User with {$role} role does not exist" ); |
| 1107 | |
| 1108 | foreach ( $caps as $cap => $roles ) { |
| 1109 | $this->assertFalse( $user->has_cap( $cap ), "User with the {$role} role should not have the {$cap} capability" ); |
| 1110 | $this->assertFalse( user_can( $user, $cap ), "User with the {$role} role should not have the {$cap} capability" ); |
| 1111 | } |
| 1112 | |
| 1113 | } |
| 1114 | |
| 1115 | if ( is_multisite() ) { |
| 1116 | $super = $this->factory->user->create_and_get( array( 'role' => 'administrator' ) ); |
| 1117 | grant_super_admin( $super->ID ); |
| 1118 | |
| 1119 | foreach ( $caps as $cap => $roles ) { |
| 1120 | $this->assertTrue( $super->has_cap( $cap ), "Super admin should have the {$cap} capability" ); |
| 1121 | $this->assertTrue( user_can( $super, $cap ), "Super admin should have the {$cap} capability" ); |
| 1122 | } |
| 1123 | |
| 1124 | } |
| 1125 | |
| 1126 | remove_filter( 'map_meta_cap', array( $this, '_return_empty_array' ) ); |
| 1127 | |
| 1128 | } |
| 1129 | |