Make WordPress Core

Changeset 50616


Ignore:
Timestamp:
03/30/2021 02:22:48 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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

Follow-up to [50613].

Props hellofromTonya.
See #51423.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php

    r50613 r50616  
    388388    }
    389389
     390    /**
     391     * Sets up the export contents.
     392     *
     393     * Tasks:
     394     * - Delete or update the '_export_data_grouped' post meta.
     395     * - Run `wp_privacy_generate_personal_data_export_file()`.
     396     * - Unzip the export package in a temporary directory to give the test access to the export files.
     397     *
     398     * @param mixed $export_data_grouped Optional. '_export_data_grouped' post meta value.
     399     *                                   When null, delete the meta; else update to the given value.
     400     * @return string Export report directory path.
     401     */
    390402    private function setup_export_contents_test( $export_data_grouped = null ) {
     403        // Delete or update the given meta.
    391404        if ( null === $export_data_grouped ) {
    392405            delete_post_meta( self::$export_request_id, '_export_data_grouped' );
     
    400413        $this->assertTrue( file_exists( $this->export_file_name ) );
    401414
     415        // Create a temporary export directory for the test's export files.
    402416        $report_dir = trailingslashit( self::$exports_dir . 'test_contents' );
    403417        mkdir( $report_dir );
    404418
     419        // Unzip the current test's export file to give the test access to .html and .json files.
    405420        $zip        = new ZipArchive();
    406421        $opened_zip = $zip->open( $this->export_file_name );
    407422        $this->assertTrue( $opened_zip );
    408 
    409423        $zip->extractTo( $report_dir );
    410424        $zip->close();
     
    414428
    415429    /**
    416      * Replace expected content's timestamp placeholder with the actual content's timestamp.
     430     * Replaces expected content's timestamp placeholder with the actual content's timestamp.
    417431     *
    418432     * Used when the expected content has a placeholder, i.e. used to avoid second time differences
Note: See TracChangeset for help on using the changeset viewer.