Make WordPress Core


Ignore:
Timestamp:
03/20/2019 05:40:17 PM (5 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/PrivacyErasePersonalData.php

    r44909 r44943  
    141141
    142142        $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        }
    143147    }
    144148
     
    149153        remove_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_custom_personal_data_eraser' ) );
    150154        $this->new_callback_value = '';
     155
     156        if ( is_multisite() ) {
     157            revoke_super_admin( get_current_user_id() );
     158        }
    151159
    152160        parent::tearDown();
     
    295303        $this->assertFalse( current_user_can( 'erase_others_personal_data' ) );
    296304        $this->assertFalse( current_user_can( 'delete_users' ) );
     305
     306        $this->_make_ajax_call();
     307
     308        $this->assertFalse( $this->_last_response_parsed['success'] );
     309        $this->assertSame( 'Sorry, you are not allowed to perform this action.', $this->_last_response_parsed['data'] );
     310    }
     311
     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() );
    297325
    298326        $this->_make_ajax_call();
Note: See TracChangeset for help on using the changeset viewer.