Docs: Add documentation for the ::setup_export_contents_test method used in personal data export tests.

Follow-up to [50613].

Props hellofromTonya.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@50616 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-03-30 14:22:48 +00:00
parent 04ff8f4561
commit 722ce44ead

@ -387,7 +387,20 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
$this->assertSame( $expected, $actual_json );
}
/**
* Sets up the export contents.
*
* Tasks:
* - Delete or update the '_export_data_grouped' post meta.
* - Run `wp_privacy_generate_personal_data_export_file()`.
* - Unzip the export package in a temporary directory to give the test access to the export files.
*
* @param mixed $export_data_grouped Optional. '_export_data_grouped' post meta value.
* When null, delete the meta; else update to the given value.
* @return string Export report directory path.
*/
private function setup_export_contents_test( $export_data_grouped = null ) {
// Delete or update the given meta.
if ( null === $export_data_grouped ) {
delete_post_meta( self::$export_request_id, '_export_data_grouped' );
} else {
@ -399,13 +412,14 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
wp_privacy_generate_personal_data_export_file( self::$export_request_id );
$this->assertTrue( file_exists( $this->export_file_name ) );
// Create a temporary export directory for the test's export files.
$report_dir = trailingslashit( self::$exports_dir . 'test_contents' );
mkdir( $report_dir );
// Unzip the current test's export file to give the test access to .html and .json files.
$zip = new ZipArchive();
$opened_zip = $zip->open( $this->export_file_name );
$this->assertTrue( $opened_zip );
$zip->extractTo( $report_dir );
$zip->close();
@ -413,7 +427,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
}
/**
* Replace expected content's timestamp placeholder with the actual content's timestamp.
* Replaces expected content's timestamp placeholder with the actual content's timestamp.
*
* Used when the expected content has a placeholder, i.e. used to avoid second time differences
* between the test and code.