Index: tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php
===================================================================
--- tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php	(nonexistent)
+++ tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php	(working copy)
@@ -0,0 +1,95 @@
+<?php
+/**
+ * Define a class to test `wp_privacy_delete_old_export_files()`.
+ *
+ * @package WordPress
+ * @subpackage UnitTests
+ * @since 4.9.6
+ */
+
+/**
+ * Test cases for `wp_privacy_delete_old_export_files()`.
+ *
+ * @group privacy
+ * @covers wp_privacy_delete_old_export_files
+ *
+ * @since 4.9.6
+*/
+class Tests_Privacy_wpPrivacyDeleteOldExportFiles extends WP_UnitTestCase {
+	/**
+	 * Silence is golden index.html path
+	 *
+	 * @since 4.9.6
+	 *
+	 * @var string $index_path
+	 */
+	protected static $index_path;
+
+	/**
+	 * Old export file path
+	 *
+	 * @since 4.9.6
+	 *
+	 * @var string $old_export_file_path
+	 */
+	protected static $old_export_file_path;
+
+	/**
+	 * New export file path
+	 *
+	 * @since 4.9.6
+	 *
+	 * @var string $old_export_file_path
+	 */
+	protected static $new_export_file_path;
+
+	/**
+	 * Create fixtures that are shared by multiple test cases.
+	 *
+	 * @param WP_UnitTest_Factory $factory The base factory object.
+	 */
+	public static function wpSetUpBeforeClass( $factory ) {
+		$exports_dir                = wp_normalize_path( trailingslashit( wp_privacy_exports_dir() ) );
+
+		if ( ! is_dir( $exports_dir ) ) {
+			wp_mkdir_p( $exports_dir );
+		}
+
+		self::$index_path           = $exports_dir . 'index.html';
+		self::$old_export_file_path = $exports_dir . 'wp-personal-data-file-user-at-example-com-0123456789abcdef.zip';
+		self::$new_export_file_path = $exports_dir . 'wp-personal-data-file-user-at-example-com-fedcba9876543210.zip';
+
+		wp_delete_file( self::$index_path );
+		wp_delete_file( self::$old_export_file_path );
+		wp_delete_file( self::$new_export_file_path );
+	}
+
+	public function setUp() {
+		parent::setUp();
+		remove_all_filters( 'wp_privacy_exports_dir' );
+	}
+
+	public function test_wp_privacy_delete_old_export_files_ignores_missing_exports_dir() {
+		add_filter( 'wp_privacy_exports_dir', array( $this, 'filter_bad_exports_dir' ) );
+		wp_privacy_delete_old_export_files();
+
+		// No notice? We pass!
+		$this->assertTrue( true );
+	}
+
+	function filter_bad_exports_dir( $file ) {
+		return dirname( __FILE__ ) . 'invalid';
+	}
+
+	public function test_wp_privacy_delete_old_export_files_deletes_just_old_files() {
+		touch( self::$index_path, time() - 5 * DAY_IN_SECONDS );
+		touch( self::$old_export_file_path, time() - 5 * DAY_IN_SECONDS );
+		touch( self::$new_export_file_path, time() );
+
+		wp_privacy_delete_old_export_files();
+
+		$this->assertTrue( file_exists( self::$index_path ) );
+		$this->assertFalse( file_exists( self::$old_export_file_path ) );
+		$this->assertTrue( file_exists( self::$new_export_file_path ) );
+	}
+}
