WordPress.org

Make WordPress Core

Ticket #44721: 44721.5.diff

File 44721.5.diff, 9.6 KB (added by garrett-eclipse, 9 months ago)

Add missing @since to new tests

  • src/wp-includes/user.php

     
    31433143                return;
    31443144        }
    31453145
     3146        // Localize message content for user; fallback to site default for visitors.
     3147        if ( ! empty( $request->user_id ) ) {
     3148                $locale = get_user_locale( $request->user_id );
     3149        } else {
     3150                $locale = get_locale();
     3151        }
     3152
     3153        $switched_locale = switch_to_locale( $locale );
     3154
    31463155        /**
    31473156         * Filters the recipient of the data erasure fulfillment notification.
    31483157         *
     
    32533262
    32543263        $email_sent = wp_mail( $user_email, $subject, $content );
    32553264
     3265        if ( $switched_locale ) {
     3266                restore_previous_locale();
     3267        }
     3268
    32563269        if ( $email_sent ) {
    32573270                update_post_meta( $request_id, '_wp_user_notified', true );
    32583271        }
  • tests/phpunit/data/languages/de_DE.po

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    22# This file is distributed under the same license as the 4.9.x package.
    33msgid ""
    44msgstr ""
    5 "PO-Revision-Date: 2018-08-13 19:19+0300\n"
     5"PO-Revision-Date: 2018-05-15 19:19+0300\n"
    66"MIME-Version: 1.0\n"
    77"Content-Type: text/plain; charset=UTF-8\n"
    88"Content-Transfer-Encoding: 8bit\n"
    99"Plural-Forms: nplurals=2; plural=n != 1;\n"
    1010"X-Generator: Poedit 2.1.1\n"
    11 "Project-Id-Version: Development (4.9.x)\n"
     11"Project-Id-Version: Development (5.2.x)\n"
    1212"Language: de_DE\n"
    1313"POT-Creation-Date: \n"
    1414"Last-Translator: \n"
     
    4848#: wp-includes/user.php:3445
    4949msgid "[%1$s] Confirm Action: %2$s"
    5050msgstr "[%1$s] Aktion bestätigen: %2$s"
     51
     52#. translators: %s: Site name.
     53#: wp-includes/user.php:3175
     54msgid "[%s] Erasure Request Fulfilled"
     55msgstr "[%s] Löschauftrag ausgeführt"
  • tests/phpunit/data/languages/es_ES.po

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    22# This file is distributed under the same license as the Development (4.9.x) package.
    33msgid ""
    44msgstr ""
    5 "PO-Revision-Date: 2018-08-13 19:19+0300\n"
     5"PO-Revision-Date: 2019-03-16 02:41-0700\n"
    66"MIME-Version: 1.0\n"
    77"Content-Type: text/plain; charset=UTF-8\n"
    88"Content-Transfer-Encoding: 8bit\n"
    99"Plural-Forms: nplurals=2; plural=n != 1;\n"
    10 "X-Generator: Poedit 2.1.1\n"
    11 "Project-Id-Version: Development (4.9.x)\n"
     10"X-Generator: Poedit 2.2\n"
     11"Project-Id-Version: Development (5.2.x)\n"
    1212"Language: es_ES\n"
    1313"POT-Creation-Date: \n"
    1414"Last-Translator: \n"
     
    4444#: wp-includes/user.php:3445
    4545msgid "[%1$s] Confirm Action: %2$s"
    4646msgstr "[%1$s] Confirma la acción: %2$s"
     47
     48#. translators: %s: Site name.
     49#: wp-includes/user.php:3175
     50msgid "[%s] Erasure Request Fulfilled"
     51msgstr "[%s] Solicitud de borrado completada"
  • tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.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         * Create user request fixtures shared by test methods.
    3957         *
    4058         * @since 5.1.0
     
    4361         */
    4462        public static function wpSetUpBeforeClass( $factory ) {
    4563                self::$requester_email = 'erase-my-data@local.test';
    46                 self::$request_id      = wp_create_user_request( self::$requester_email, 'erase_personal_data' );
     64                self::$request_user    = $factory->user->create_and_get(
     65                        array(
     66                                'user_email' => self::$requester_email,
     67                                'role'       => 'subscriber',
     68                        )
     69                );
     70                self::$admin_user      = $factory->user->create_and_get(
     71                        array(
     72                                'user_email' => 'admin@local.dev',
     73                                'role'       => 'administrator',
     74                        )
     75                );
     76
     77                self::$request_id = wp_create_user_request( self::$requester_email, 'remove_personal_data' );
    4778                wp_update_post(
    4879                        array(
    4980                                'ID'          => self::$request_id,
     
    69100         */
    70101        public function tearDown() {
    71102                reset_phpmailer_instance();
     103                restore_previous_locale();
    72104                parent::tearDown();
    73105        }
    74106
     
    276308                $this->assertFalse( metadata_exists( 'post', self::$request_id, '_wp_user_notified' ) );
    277309        }
    278310
     311        /**
     312         * The function should respect the user locale settings when the site uses the default locale.
     313         *
     314         * @since 5.2.0
     315         * @ticket 44721
     316         * @group l10n
     317         */
     318        public function test_should_send_fulfillment_email_in_user_locale() {
     319                update_user_meta( self::$request_user->ID, 'locale', 'es_ES' );
     320
     321                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
     322                $mailer = tests_retrieve_phpmailer_instance();
     323
     324                $this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject );
     325        }
     326
     327        /**
     328         * The function should respect the user locale settings when the site does not use en_US, the administrator
     329         * uses the site's default locale, and the user has a different locale.
     330         *
     331         * @since 5.2.0
     332         * @ticket 44721
     333         * @group l10n
     334         */
     335        public function test_should_send_fulfillment_email_in_user_locale_when_site_is_not_en_us() {
     336                update_option( 'WPLANG', 'es_ES' );
     337                switch_to_locale( 'es_ES' );
     338
     339                update_user_meta( self::$request_user->ID, 'locale', 'de_DE' );
     340                wp_set_current_user( self::$admin_user->ID );
     341
     342                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
     343                $mailer = tests_retrieve_phpmailer_instance();
     344
     345                $this->assertContains( 'Löschauftrag ausgeführt', $mailer->get_sent()->subject );
     346        }
     347
     348        /**
     349         * The function should respect the user locale settings when the site is not en_US, the administrator
     350         * has a different selected locale, and the user uses the site's default locale.
     351         *
     352         * @since 5.2.0
     353         * @ticket 44721
     354         * @group l10n
     355         */
     356        public function test_should_send_fulfillment_email_in_user_locale_when_admin_and_site_have_different_locales() {
     357                update_option( 'WPLANG', 'es_ES' );
     358                switch_to_locale( 'es_ES' );
     359
     360                update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' );
     361                wp_set_current_user( self::$admin_user->ID );
     362
     363                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
     364                $mailer = tests_retrieve_phpmailer_instance();
     365
     366                $this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject );
     367        }
     368
     369        /**
     370         * The function should respect the user locale settings when the site is not en_US and both the
     371         * administrator and the user use different locales.
     372         *
     373         * @since 5.2.0
     374         * @ticket 44721
     375         * @group l10n
     376         */
     377        public function test_should_send_fulfillment_email_in_user_locale_when_both_have_different_locales_than_site() {
     378                update_option( 'WPLANG', 'es_ES' );
     379                switch_to_locale( 'es_ES' );
     380
     381                update_user_meta( self::$admin_user->ID, 'locale', 'en_US' );
     382                update_user_meta( self::$request_user->ID, 'locale', 'de_DE' );
     383
     384                wp_set_current_user( self::$admin_user->ID );
     385
     386                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
     387                $mailer = tests_retrieve_phpmailer_instance();
     388
     389                $this->assertContains( 'Löschauftrag ausgeführt', $mailer->get_sent()->subject );
     390        }
     391
     392        /**
     393         * The function should respect the site's locale when the request is for an unregistered user and the
     394         * administrator does not use the site's locale.
     395         *
     396         * @since 5.2.0
     397         * @ticket 44721
     398         * @group l10n
     399         */
     400        public function test_should_send_fulfillment_email_in_site_locale() {
     401                update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' );
     402                wp_set_current_user( self::$admin_user->ID );
     403
     404                $request_id = wp_create_user_request( 'erase-user-not-registered@example.com', 'remove_personal_data' );
     405                wp_update_post(
     406                        array(
     407                                'ID'          => $request_id,
     408                                'post_status' => 'request-completed',
     409                        )
     410                );
     411
     412                _wp_privacy_send_erasure_fulfillment_notification( $request_id );
     413                $mailer = tests_retrieve_phpmailer_instance();
     414
     415                $this->assertContains( 'Erasure Request Fulfilled', $mailer->get_sent()->subject );
     416        }
     417
     418        /**
     419         * The function should respect the site's locale when it is not en_US, the request is for an
     420         * unregistered user, and the administrator does not use the site's default locale.
     421         *
     422         * @since 5.2.0
     423         * @ticket 44721
     424         * @group l10n
     425         */
     426        public function test_should_send_fulfillment_email_in_site_locale_when_not_en_us_and_admin_has_different_locale() {
     427                update_option( 'WPLANG', 'es_ES' );
     428                switch_to_locale( 'es_ES' );
     429
     430                update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' );
     431                wp_set_current_user( self::$admin_user->ID );
     432
     433                $request_id = wp_create_user_request( 'erase-user-not-registered@example.com', 'remove_personal_data' );
     434                wp_update_post(
     435                        array(
     436                                'ID'          => $request_id,
     437                                'post_status' => 'request-completed',
     438                        )
     439                );
     440
     441                _wp_privacy_send_erasure_fulfillment_notification( $request_id );
     442                $mailer = tests_retrieve_phpmailer_instance();
     443
     444                $this->assertContains( 'Solicitud de borrado completada', $mailer->get_sent()->subject );
     445        }
    279446}