Skip to content

Commit 7d22ba1

Browse files
committed
Privacy: Add test for wp_privacy_export_expiration filter.
Props desrosj. See #44233. git-svn-id: https://develop.svn.wordpress.org/trunk@43640 602fd350-edb4-49c9-b593-d223f7449a82
1 parent df261c6 commit 7d22ba1

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Test cases for `wp_privacy_delete_old_export_files()`.
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
1717
*/
@@ -143,4 +143,30 @@ public function test_index_file_should_never_be_deleted() {
143143

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
}

0 commit comments

Comments
 (0)