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

WordPress Trac noreply at wordpress.org
Wed Jul 4 13:22:54 UTC 2018


#44233: Add missing unit tests for exporting personal data by username or email
address
-------------------------+------------------------
 Reporter:  desrosj      |       Owner:  desrosj
     Type:  enhancement  |      Status:  reviewing
 Priority:  low          |   Milestone:  4.9.7
Component:  Privacy      |     Version:  4.9.6
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+------------------------

Comment (by birgire):

 It's not easy to test
 {{{wp_privacy_generate_personal_data_export_file()}}}, so thumbs up 👍 to
 @allendav.

 I tested {{{Tests_Privacy_wpPrivacyGeneratePersonalDataExportFile}}}
 successfully, but noticed that it left behind some files and a
 subdirectory, in the privacy export directory.

 [attachment:"44233.3.diff"] includes suggestions that:

 - Renames the class to
 {{{Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile}}}.
 - Avoids the exec/shell execution to remove the privacy export directory.
 - Introduces the {{{remove_exports_dir()}}} helper method, that uses the
 {{{list_files()}}} function that already exists in core. First I did
 consider expanding and using the {{{remove_added_uploads()}}},
 {{{files_in_dir()}}}, {{{scan_dir()}}} and {{{delete_folders()}}} methods
 of {{{WP_UnitTestCase}}}. That should be possible, but e.g. the
 {{{RecursiveDirectoryIterator::SKIP_DOTS}}} is not supported in PHP 5.2.
 - Makes an extra check on the privacy export directory path, to avoid it's
 corrupted by filters, when it's removed.
 - Adds extra checks to skip tests.
 - Makes sure all test files/directories are removed, before and after each
 test run.
 - Simplifies the name of the test methods, use {{{"test_function_..."}}}
 instead of {{{"test_wp_privacy_generate_personal_data_export_file_..."}}}.

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


More information about the wp-trac mailing list