Make WordPress Core

Ticket #46056: 46056.3.diff

File 46056.3.diff, 9.3 KB (added by garrett-eclipse, 5 years ago)

Refresh to account for #44721 being committed - Changed are isolated to .po test files. .mo versions coming shortly

  • src/wp-admin/includes/file.php

     
    23532353                return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
    23542354        }
    23552355
     2356        // Localize message content for user; fallback to site default for visitors.
     2357        if ( ! empty( $request->user_id ) ) {
     2358                $locale = get_user_locale( $request->user_id );
     2359        } else {
     2360                $locale = get_locale();
     2361        }
     2362
     2363        $switched_locale = switch_to_locale( $locale );
     2364
    23562365        /** This filter is documented in wp-includes/functions.php */
    23572366        $expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
    23582367        $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
     
    24092418                $content
    24102419        );
    24112420
     2421        if ( $switched_locale ) {
     2422                restore_previous_locale();
     2423        }
     2424
    24122425        if ( ! $mail_success ) {
    24132426                return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
    24142427        }
  • tests/phpunit/data/languages/de_DE.po

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    1 # Translation of 4.9.x in German
    2 # This file is distributed under the same license as the 4.9.x package.
     1# Translation of 5.2.x in German
     2# This file is distributed under the same license as the 5.2.x package.
    33msgid ""
    44msgstr ""
    55"PO-Revision-Date: 2019-03-27 22:27+0300\n"
     
    5353#: wp-includes/user.php:3175
    5454msgid "[%s] Erasure Request Fulfilled"
    5555msgstr "[%s] Löschauftrag ausgeführt"
     56
     57#: wp-admin/includes/file.php:2415
     58msgid "[%s] Personal Data Export"
     59msgstr "[%s] Export personenbezogener Daten"
     60 No newline at end of file
  • tests/phpunit/data/languages/es_ES.po

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    1 # Translation of Development (4.9.x) in Spanish (Spain)
    2 # This file is distributed under the same license as the Development (4.9.x) package.
     1# Translation of Development (5.2.x) in Spanish (Spain)
     2# This file is distributed under the same license as the Development (5.2.x) package.
    33msgid ""
    44msgstr ""
    55"PO-Revision-Date: 2019-03-27 22:27+0300\n"
     
    4949#: wp-includes/user.php:3175
    5050msgid "[%s] Erasure Request Fulfilled"
    5151msgstr "[%s] Solicitud de borrado completada"
     52
     53#: wp-admin/includes/file.php:2415
     54msgid "[%s] Personal Data Export"
     55msgstr "[%s] Exportación de datos personales"
     56 No newline at end of file
  • tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php

     
    3535        protected static $requester_email;
    3636
    3737        /**
     38         * Request user.
     39         *
     40         * @since 5.2.0
     41         *
     42         * @var WP_User $request_user
     43         */
     44        protected static $request_user;
     45
     46        /**
     47         * Test administrator user.
     48         *
     49         * @since 5.2.0
     50         *
     51         * @var WP_User $admin_user
     52         */
     53        protected static $admin_user;
     54
     55        /**
    3856         * Reset the mocked phpmailer instance before each test method.
    3957         *
    4058         * @since 4.9.6
     
    5169         */
    5270        public function tearDown() {
    5371                reset_phpmailer_instance();
     72                restore_previous_locale();
    5473                parent::tearDown();
    5574        }
    5675
     
    6382         */
    6483        public static function wpSetUpBeforeClass( $factory ) {
    6584                self::$requester_email = 'requester@example.com';
     85                self::$request_user    = $factory->user->create_and_get(
     86                        array(
     87                                'user_email' => self::$requester_email,
     88                                'role'       => 'subscriber',
     89                        )
     90                );
     91                self::$admin_user      = $factory->user->create_and_get(
     92                        array(
     93                                'user_email' => 'admin@local.dev',
     94                                'role'       => 'administrator',
     95                        )
     96                );
     97
    6698                self::$request_id      = wp_create_user_request( self::$requester_email, 'export_personal_data' );
    6799
    68100                _wp_privacy_account_request_confirmed( self::$request_id );
     
    167199        public function modify_email_content( $email_text, $request_id ) {
    168200                return 'Custom content for request ID: ' . $request_id;
    169201        }
     202
     203        /**
     204         * The function should respect the user locale settings when the site uses the default locale.
     205         *
     206         * @since 5.2.0
     207         * @ticket 46056
     208         * @group l10n
     209         */
     210        public function test_should_send_personal_data_export_email_in_user_locale() {
     211                update_user_meta( self::$request_user->ID, 'locale', 'es_ES' );
     212
     213                wp_privacy_send_personal_data_export_email( self::$request_id );
     214               
     215                $mailer = tests_retrieve_phpmailer_instance();
     216
     217                $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject );
     218        }
     219
     220        /**
     221         * The function should respect the user locale settings when the site does not use en_US, the administrator
     222         * uses the site's default locale, and the user has a different locale.
     223         *
     224         * @since 5.2.0
     225         * @ticket 46056
     226         * @group l10n
     227         */
     228        public function test_should_send_personal_data_export_email_in_user_locale_when_site_is_not_en_us() {
     229                update_option( 'WPLANG', 'es_ES' );
     230                switch_to_locale( 'es_ES' );
     231
     232                update_user_meta( self::$request_user->ID, 'locale', 'de_DE' );
     233                wp_set_current_user( self::$admin_user->ID );
     234
     235                wp_privacy_send_personal_data_export_email( self::$request_id );
     236
     237                $mailer = tests_retrieve_phpmailer_instance();
     238
     239                $this->assertContains( 'Export personenbezogener Daten', $mailer->get_sent()->subject );
     240        }
     241
     242        /**
     243         * The function should respect the user locale settings when the site is not en_US, the administrator
     244         * has a different selected locale, and the user uses the site's default locale.
     245         *
     246         * @since 5.2.0
     247         * @ticket 46056
     248         * @group l10n
     249         */
     250        public function test_should_send_personal_data_export_email_in_user_locale_when_admin_and_site_have_different_locales() {
     251                update_option( 'WPLANG', 'es_ES' );
     252                switch_to_locale( 'es_ES' );
     253
     254                update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' );
     255                wp_set_current_user( self::$admin_user->ID );
     256
     257                wp_privacy_send_personal_data_export_email( self::$request_id );
     258
     259                $mailer = tests_retrieve_phpmailer_instance();
     260
     261                $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject );
     262        }
     263
     264        /**
     265         * The function should respect the user locale settings when the site is not en_US and both the
     266         * administrator and the user use different locales.
     267         *
     268         * @since 5.2.0
     269         * @ticket 46056
     270         * @group l10n
     271         */
     272        public function test_should_send_personal_data_export_email_in_user_locale_when_both_have_different_locales_than_site() {
     273                update_option( 'WPLANG', 'es_ES' );
     274                switch_to_locale( 'es_ES' );
     275
     276                update_user_meta( self::$admin_user->ID, 'locale', 'en_US' );
     277                update_user_meta( self::$request_user->ID, 'locale', 'de_DE' );
     278
     279                wp_set_current_user( self::$admin_user->ID );
     280
     281                wp_privacy_send_personal_data_export_email( self::$request_id );
     282
     283                $mailer = tests_retrieve_phpmailer_instance();
     284
     285                $this->assertContains( 'Export personenbezogener Daten', $mailer->get_sent()->subject );
     286        }
     287
     288        /**
     289         * The function should respect the site's locale when the request is for an unregistered user and the
     290         * administrator does not use the site's locale.
     291         *
     292         * @since 5.2.0
     293         * @ticket 46056
     294         * @group l10n
     295         */
     296        public function test_should_send_personal_data_export_email_in_site_locale() {
     297                update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' );
     298                wp_set_current_user( self::$admin_user->ID );
     299
     300                $request_id = wp_create_user_request( 'export-user-not-registered@example.com', 'export_personal_data' );
     301
     302                _wp_privacy_account_request_confirmed( self::$request_id );
     303                wp_privacy_send_personal_data_export_email( $request_id );
     304
     305                $mailer = tests_retrieve_phpmailer_instance();
     306
     307                $this->assertContains( 'Personal Data Export', $mailer->get_sent()->subject );
     308        }
     309
     310        /**
     311         * The function should respect the site's locale when it is not en_US, the request is for an
     312         * unregistered user, and the administrator does not use the site's default locale.
     313         *
     314         * @since 5.2.0
     315         * @ticket 46056
     316         * @group l10n
     317         */
     318        public function test_should_send_personal_data_export_email_in_site_locale_when_not_en_us_and_admin_has_different_locale() {
     319                update_option( 'WPLANG', 'es_ES' );
     320                switch_to_locale( 'es_ES' );
     321
     322                update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' );
     323                wp_set_current_user( self::$admin_user->ID );
     324
     325                $request_id = wp_create_user_request( 'export-user-not-registered@example.com', 'export_personal_data' );
     326
     327                _wp_privacy_account_request_confirmed( self::$request_id );
     328                wp_privacy_send_personal_data_export_email( $request_id );
     329
     330                $mailer = tests_retrieve_phpmailer_instance();
     331
     332                $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject );
     333        }
    170334}