[wp-trac] [WordPress Trac] #44234: Add missing unit tests for erasing personal data by username or email address

WordPress Trac noreply at wordpress.org
Fri Sep 14 12:41:06 UTC 2018


#44234: Add missing unit tests for erasing personal data by username or email
address
-------------------------------------------------+-------------------------
 Reporter:  desrosj                              |       Owner:  desrosj
     Type:  enhancement                          |      Status:  assigned
 Priority:  low                                  |   Milestone:  4.9.9
Component:  Privacy                              |     Version:  4.9.6
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing                                        |  administration
-------------------------------------------------+-------------------------

Comment (by birgire):

 @desrosj [attachment:"44234.diff"] looks good.

 [attachment:"44234-2.diff"] contains few suggestions:

 - Adds test cases for the filters:
  - {{{user_erasure_fulfillment_email_to}}},
  - {{{user_erasure_complete_email_subject}}},
  - {{{user_confirmed_action_email_content}}}.
 I only used the first input argument of those filter, so it's open for
 improvements to add the other arguments.
 - Fixes the request type from {{{'earase_personal_data'}}} to
 {{{'remove_personal_data'}}}. It's defined as the latter in the
 {{{WP_Privacy_Data_Removal_Requests_Table}}} class. But in general I would
 have preferred the {{{'earase_personal_data'}}} name of that action type
 :-)
 - Adds {{{::}}} for the global function in the {{{@covers}}} annotation
 for {{{_wp_privacy_send_erasure_fulfillment_notification}}}.
 - Uses "send an email" instead of "send emails" in inline method
 descriptions, to make it clear that it only sends a single email.
 - The unit tests are a useful documentation, so what about changing the
 order of methods; show first the methods that explain how it should work,
 then after that the methods for failing/error? This is applied in the
 patch.
 - Adds inline comments within methods:
         - {{{test_should_send_email_only_once()}}},
         - {{{test_should_not_send_email_when_request_not_completed()}}},
         - {{{test_should_not_send_email_when_not_wp_user_request()}}}.
 - Adjusted the description of the
 {{{test_should_not_send_email_when_not_wp_user_request()}}} method.
 - Changes {{{'erase-my-data at local.dev'}}} to {{{'erase-my-
 data at local.test'}}} as the {{{.dev}}} domain is no longer suitable for
 local.
 - The {{{$mailer->get_sent()->to}}} is:
 {{{
 [0] => Array
    (
                 [0] => erase-my-data at local.test
                 [1] =>
         )
 )
 }}}
 so it seems like {{{$mailer->get_sent()->to[0][0]}}} should be used
 instead of {{{$mailer->get_sent()->to[0]}}}.
 I used {{{$mailer->get_recipient( 'to' )->address}}} instead, as it is a
 wrapper for {{{$mailer->get_sent()->to}}}.
 - Moves
 {{{
 wp_update_post(
         array(
                 'ID'          => self::$request_id,
                 'post_status' => 'request-completed',
         )
 );
 }}}
 into the {{{wpSetUpBeforeClass()}}} method to reduce code duplications, as
 I was also starting to use it in the new methods.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44234#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list