Make WordPress Core


Ignore:
Timestamp:
03/20/2019 05:40:17 PM (8 years ago)
Author:
desrosj
Message:

Tests: Fix failing tests for privacy export/erase requests when running the ajax group for multisite.

Props davidbinda, garrett-eclipse.
Fixes #43438.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/PrivacyExportPersonalData.php

    r44909 r44943  
    155155
    156156                $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                }
    157161        }
    158162
    … …  
    163167                remove_filter( 'wp_privacy_personal_data_exporters', array( $this, 'filter_register_custom_personal_data_exporter' ) );
    164168
     169                if ( is_multisite() ) {
     170                        revoke_super_admin( get_current_user_id() );
     171                }
    165172                parent::tearDown();
    166173        }
    … …  
    261268                $this->assertFalse( $this->_last_response_parsed['success'] );
    262269                $this->assertFalse( current_user_can( 'export_others_personal_data' ) );
     270                $this->assertSame( 'Sorry, you are not allowed to perform this action.', $this->_last_response_parsed['data'] );
     271        }
     272
     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'] );
    263290                $this->assertSame( 'Sorry, you are not allowed to perform this action.', $this->_last_response_parsed['data'] );
    264291        }
Note: See TracChangeset for help on using the changeset viewer.