Ticket #43438: 43438.22.diff
File 43438.22.diff, 3.3 KB (added by , 6 years ago) |
---|
-
tests/phpunit/tests/ajax/PrivacyErasePersonalData.php
140 140 add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_custom_personal_data_eraser' ) ); 141 141 142 142 $this->_setRole( 'administrator' ); 143 // erase_others_personal_data meta cap in Multisite installation is only granted to those with `manage_network` capability. 144 if ( is_multisite() ) { 145 grant_super_admin( get_current_user_id() ); 146 } 143 147 } 144 148 145 149 /** … … 149 153 remove_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_custom_personal_data_eraser' ) ); 150 154 $this->new_callback_value = ''; 151 155 156 if ( is_multisite() ) { 157 revoke_super_admin( get_current_user_id() ); 158 } 159 152 160 parent::tearDown(); 153 161 } 154 162 … … 302 310 } 303 311 304 312 /** 313 * Test requests do not succeed on multisite when the current user is not a network admin. 314 * 315 * @group multisite 316 * 317 * @ticket 43438 318 */ 319 public function test_error_when_current_user_missing_required_capabilities_multisite() { 320 if ( ! is_multisite() ) { 321 $this->markTestSkipped( 'This test only runs on multisite.' ); 322 } 323 324 revoke_super_admin( get_current_user_id() ); 325 326 $this->_make_ajax_call(); 327 328 $this->assertFalse( $this->_last_response_parsed['success'] ); 329 $this->assertSame( 'Sorry, you are not allowed to perform this action.', $this->_last_response_parsed['data'] ); 330 } 331 332 /** 305 333 * The function should send an error when the nonce does not validate. 306 334 * 307 335 * @since 5.2.0 -
tests/phpunit/tests/ajax/PrivacyExportPersonalData.php
154 154 add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'filter_register_custom_personal_data_exporter' ) ); 155 155 156 156 $this->_setRole( 'administrator' ); 157 // export_others_personal_data meta cap in Multisite installation is only granted to those with `manage_network` capability. 158 if ( is_multisite() ) { 159 grant_super_admin( get_current_user_id() ); 160 } 157 161 } 158 162 159 163 /** … … 162 166 public function tearDown() { 163 167 remove_filter( 'wp_privacy_personal_data_exporters', array( $this, 'filter_register_custom_personal_data_exporter' ) ); 164 168 169 if ( is_multisite() ) { 170 revoke_super_admin( get_current_user_id() ); 171 } 165 172 parent::tearDown(); 166 173 } 167 174 … … 264 271 } 265 272 266 273 /** 274 * Test requests do not succeed on multisite when the current user is not a network admin. 275 * 276 * @group multisite 277 * 278 * @ticket 43438 279 */ 280 public function test_error_when_current_user_missing_required_capability_multisite() { 281 if ( ! is_multisite() ) { 282 $this->markTestSkipped( 'This test only runs on multisite.' ); 283 } 284 285 revoke_super_admin( get_current_user_id() ); 286 287 $this->_make_ajax_call(); 288 289 $this->assertFalse( $this->_last_response_parsed['success'] ); 290 $this->assertSame( 'Sorry, you are not allowed to perform this action.', $this->_last_response_parsed['data'] ); 291 } 292 293 /** 267 294 * The function should send an error when the nonce does not validate. 268 295 * 269 296 * @since 5.2.0