Make WordPress Core


Ignore:
Timestamp:
02/10/2020 05:30:03 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Privacy: Include community-events-location user meta value in Personal Data Export.

The value is used by the WordPress Events and News widget to show relevant WP community events.

The location information may include an IP address, location description, and latitude/longitude coordinates.

Props garrett-eclipse, coreymckrill, xkon.
Fixes #43921.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user.php

    r47122 r47236  
    16521652
    16531653    /**
    1654      * Testing the `wp_user_personal_data_exporter_no_user` function when no user exists.
     1654     * Testing the `wp_user_personal_data_exporter()` function when no user exists.
    16551655     *
    16561656     * @ticket 43547
     
    16681668
    16691669    /**
    1670      * Testing the `wp_user_personal_data_exporter_no_user` function when the requested
     1670     * Testing the `wp_user_personal_data_exporter()` function when the requested
    16711671     * user exists.
    16721672     *
     
    16861686        $this->assertSame( 11, count( $actual['data'][0]['data'] ) );
    16871687    }
     1688
     1689    /**
     1690     * Testing the `wp_user_personal_data_exporter()` function
     1691     * with Community Events Location IP data.
     1692     *
     1693     * @ticket 43921
     1694     */
     1695    function test_wp_community_events_location_ip_personal_data_exporter() {
     1696        $test_user = new WP_User( self::$contrib_id );
     1697
     1698        $location_data = array( 'ip' => '0.0.0.0' );
     1699        update_user_option( $test_user->ID, 'community-events-location', $location_data, true );
     1700
     1701        $actual = wp_user_personal_data_exporter( $test_user->user_email );
     1702
     1703        $this->assertTrue( $actual['done'] );
     1704
     1705        // Contains 'Community Events Location'.
     1706        $this->assertEquals( 'Community Events Location', $actual['data'][1]['group_label'] );
     1707
     1708        // Contains location IP.
     1709        $this->assertEquals( 'IP', $actual['data'][1]['data'][0]['name'] );
     1710        $this->assertEquals( '0.0.0.0', $actual['data'][1]['data'][0]['value'] );
     1711    }
     1712
     1713    /**
     1714     * Testing the `wp_user_personal_data_exporter()` function
     1715     * with Community Events Location city data.
     1716     *
     1717     * @ticket 43921
     1718     */
     1719    function test_wp_community_events_location_city_personal_data_exporter() {
     1720        $test_user = new WP_User( self::$contrib_id );
     1721
     1722        $location_data = array(
     1723            'description' => 'Cincinnati',
     1724            'country'     => 'US',
     1725            'latitude'    => '39.1271100',
     1726            'longitude'   => '-84.5143900',
     1727        );
     1728        update_user_option( $test_user->ID, 'community-events-location', $location_data, true );
     1729
     1730        $actual = wp_user_personal_data_exporter( $test_user->user_email );
     1731
     1732        $this->assertTrue( $actual['done'] );
     1733
     1734        // Contains 'Community Events Location'.
     1735        $this->assertEquals( 'Community Events Location', $actual['data'][1]['group_label'] );
     1736
     1737        // Contains location city.
     1738        $this->assertEquals( 'City', $actual['data'][1]['data'][0]['name'] );
     1739        $this->assertEquals( 'Cincinnati', $actual['data'][1]['data'][0]['value'] );
     1740
     1741        // Contains location country.
     1742        $this->assertEquals( 'Country', $actual['data'][1]['data'][1]['name'] );
     1743        $this->assertEquals( 'US', $actual['data'][1]['data'][1]['value'] );
     1744
     1745        // Contains location latitude.
     1746        $this->assertEquals( 'Latitude', $actual['data'][1]['data'][2]['name'] );
     1747        $this->assertEquals( '39.1271100', $actual['data'][1]['data'][2]['value'] );
     1748
     1749        // Contains location longitude.
     1750        $this->assertEquals( 'Longitude', $actual['data'][1]['data'][3]['name'] );
     1751        $this->assertEquals( '-84.5143900', $actual['data'][1]['data'][3]['value'] );
     1752
     1753    }
    16881754}
Note: See TracChangeset for help on using the changeset viewer.