WordPress.org

Make WordPress Core

Changeset 43640


Ignore:
Timestamp:
09/13/2018 05:25:31 PM (3 years ago)
Author:
iandunn
Message:

Privacy: Add test for wp_privacy_export_expiration filter.

Props desrosj.
See #44233.

File:
1 edited

Legend:

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

    r43292 r43640  
    1212 *
    1313 * @group privacy
    14  * @covers wp_privacy_delete_old_export_files
     14 * @covers ::wp_privacy_delete_old_export_files
    1515 *
    1616 * @since 4.9.6
     
    144144        $this->assertTrue( file_exists( self::$index_path ) );
    145145    }
     146
     147    /**
     148     * Test the correct files are deleted when the expiration time is filtered.
     149     *
     150     * @since 4.9.9
     151     */
     152    public function test_filtered_expiration_time() {
     153        add_filter( 'wp_privacy_export_expiration', array( $this, 'filter_export_file_expiration_time' ) );
     154
     155        wp_privacy_delete_old_export_files();
     156        $this->assertTrue( file_exists( self::$active_export_file ) );
     157        $this->assertTrue( file_exists( self::$expired_export_file ) );
     158
     159        remove_filter( 'wp_privacy_export_expiration', array( $this, 'filter_export_file_expiration_time' ) );
     160    }
     161
     162    /**
     163     * Filters the expiration time for export files.
     164     *
     165     * @since 4.9.9
     166     *
     167     * @return int New, longer expiration time.
     168     */
     169    public function filter_export_file_expiration_time() {
     170        return 6 * DAY_IN_SECONDS;
     171    }
    146172}
Note: See TracChangeset for help on using the changeset viewer.