diff --git tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php
index 6162951..a85e2e3 100644
--- tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php
+++ tests/phpunit/tests/privacy/wpPrivacyDeleteOldExportFiles.php
@@ -143,4 +143,25 @@ class Tests_Privacy_WpPrivacyDeleteOldExportFiles extends WP_UnitTestCase {
 
 		$this->assertTrue( file_exists( self::$index_path ) );
 	}
+
+	/**
+	 * Test the correct files are deleted when the expiration time is filtered.
+	 */
+	public function test_filtered_expiration_time() {
+		add_filter( 'wp_privacy_export_expiration', array( $this, 'filter_export_file_expiration_time' ) );
+		wp_privacy_delete_old_export_files();
+
+		$this->assertTrue( file_exists( self::$active_export_file ) );
+		$this->assertTrue( file_exists( self::$expired_export_file ) );
+		remove_filter( 'wp_privacy_export_expiration', array( $this, 'filter_export_file_expiration_time' ) );
+	}
+
+	/**
+	 * Filters the expiration time for export files.
+	 *
+	 * @return int New, longer expiration time.
+	 */
+	public function filter_export_file_expiration_time() {
+		return 6 * DAY_IN_SECONDS;
+	}
 }
diff --git tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php
new file mode 100644
index 0000000..342e457
--- /dev/null
+++ tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportFile.php
@@ -0,0 +1,402 @@
+<?php
+/**
+ * Define a class to test `wp_privacy_generate_personal_data_export_file()`.
+ *
+ * @package WordPress
+ * @subpackage UnitTests
+ * @since 4.9.7
+ */
+
+/**
+ * Test cases for `wp_privacy_generate_personal_data_export_file()`.
+ *
+ * @group privacy
+ * @covers wp_privacy_generate_personal_data_export_file
+ *
+ * @since 4.9.7
+ */
+class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestCase {
+
+	/**
+	 * An Export Request ID
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $export_request_id
+	 */
+	protected static $export_request_id;
+
+	/**
+	 * Whether an exception has been thrown for the current test method.
+	 *
+	 * Will always be set to false in setUp().
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var bool $exception_was_thrown
+	 */
+	public $exception_was_thrown = false;
+
+	/**
+	 * The full path to the export file for the current test method.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var string $export_file_name
+	 */
+	public $export_file_name = '';
+
+	/**
+	 * The full path to the exports directory.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var string $exports_dir
+	 */
+	public static $exports_dir;
+
+	/**
+	 * Create fixtures that are shared by multiple test cases.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param WP_UnitTest_Factory $factory The base factory object.
+	 */
+	public static function wpSetUpBeforeClass( $factory ) {
+		self::$export_request_id = wp_create_user_request( 'export-requester@example.com', 'export_personal_data' );
+		update_post_meta( self::$export_request_id, '_export_data_grouped', array() );
+		self::$exports_dir = wp_privacy_exports_dir();
+	}
+
+	/**
+	 * Set up the test fixture.
+	 * Override wp_die(), pretend to be ajax, and suppress E_WARNINGs
+	 *
+	 * @since 4.9.7
+	 */
+	public function setUp() {
+		parent::setUp();
+
+		$this->exception_was_thrown = false;
+		$this->export_file_name     = '';
+
+		// Make sure the ZipArchive class exists, else skip test.
+		if ( ! class_exists( 'ZipArchive' ) ) {
+			$this->markTestSkipped( 'The ZipArchive class is missing.' );
+		}
+
+		// Make sure the privacy exports directory is not corrupted by any filters,
+		// because of it's removal, else skip test.
+		if ( false === strpos( self::$exports_dir, 'wp-personal-data-exports/' ) ) {
+			$this->markTestSkipped( 'Exports directory unclear. Skipping test to avoid loss of data.' );
+		}
+
+		// Remove existing privacy exports directory, else skip test.
+		if ( ! $this->remove_exports_dir() ) {
+			$this->markTestSkipped( 'Existing exports directory could not be removed. Skipping test.' );
+		}
+
+		// We need to override the die handler. Otherwise, the unit tests will die too.
+		add_filter( 'wp_die_ajax_handler', array( $this, 'get_die_handler' ), 1, 1 );
+		add_filter( 'wp_doing_ajax', '__return_true' );
+		add_action( 'wp_privacy_personal_data_export_file_created', array( $this, 'action_wp_privacy_personal_data_export_file_created' ) );
+
+		// Suppress warnings from "Cannot modify header information - headers already sent by".
+		$this->_error_level = error_reporting();
+		error_reporting( $this->_error_level & ~E_WARNING );
+	}
+
+	/**
+	 * Tear down the test fixture.
+	 *
+	 * Remove the wp_die() override, restore error reporting.
+	 *
+	 * @since 4.9.7
+	 */
+	public function tearDown() {
+		remove_filter( 'wp_die_ajax_handler', array( $this, 'get_die_handler' ), 1, 1 );
+		remove_filter( 'wp_doing_ajax', '__return_true' );
+		remove_action( 'wp_privacy_personal_data_export_file_created', array( $this, 'action_wp_privacy_personal_data_export_file_created' ) );
+
+		$this->remove_exports_dir();
+
+		error_reporting( $this->_error_level );
+		parent::tearDown();
+	}
+
+	/**
+	 * Return our callback handler.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @return callback
+	 */
+	public function get_die_handler() {
+		return array( $this, 'die_handler' );
+	}
+
+	/**
+	 * Handler for wp_die()
+	 * Don't die, throw.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param string $message (Unfortunately, always empty).
+	 * @throws Exception Throws exception when called.
+	 */
+	public function die_handler( $message ) {
+		throw new Exception();
+	}
+
+	/**
+	 * Stores the name of the export zip file to check the file is actually created.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param string $archive_name Created export zip file path.
+	 */
+	public function action_wp_privacy_personal_data_export_file_created( $archive_name ) {
+		$this->export_file_name = $archive_name;
+	}
+
+	/**
+	 * Removes the privacy exports directory, including files and subdirectories.
+	 *
+	 * Ignores hidden files and has upper limit of nested levels, because of `list_files()`.
+	 *
+	 * @return bool Whether the privacy exports directory was removed.
+	 */
+	private function remove_exports_dir() {
+		// Make sure the export directory path is not corrupted by any filter.
+		if ( false === strpos( self::$exports_dir, 'wp-personal-data-exports/' ) ) {
+			return false;
+		}
+
+		// Remove if the file exists.
+		if ( is_file( untrailingslashit( self::$exports_dir ) ) ) {
+			wp_delete_file( untrailingslashit( self::$exports_dir ) );
+			return ! is_file( untrailingslashit( self::$exports_dir ) );
+		}
+
+		// Directory already removed.
+		if ( ! is_dir( self::$exports_dir ) ) {
+			return true;
+		}
+
+		chmod( self::$exports_dir, 0755 );
+
+		// Get files and subdirectories (mixed order).
+		$files = list_files( self::$exports_dir );
+
+		// Delete files, before deleting subdirectories.
+		foreach ( $files as $file ) {
+			if ( is_file( $file ) ) {
+				wp_delete_file( $file );
+			}
+		}
+
+		// Delete subdirectories.
+		foreach ( $files as $file ) {
+			if ( is_dir( $file ) ) {
+				rmdir( $file );
+			}
+		}
+
+		// Delete main directory.
+		rmdir( self::$exports_dir );
+
+		return ! is_dir( self::$exports_dir );
+	}
+
+	/**
+	 * When a remove request ID is passed to the export function an error should be displayed.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_rejects_remove_requests() {
+		$request_id = wp_create_user_request( 'removal-requester@example.com', 'remove_personal_data' );
+
+		try {
+			$this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating export file."}' );
+			wp_privacy_generate_personal_data_export_file( $request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertTrue( $this->exception_was_thrown );
+	}
+
+	/**
+	 * When an invalid request ID is passed an error should be displayed.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_invalid_request_id() {
+		try {
+			$this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating export file."}' );
+			wp_privacy_generate_personal_data_export_file( 123456789 );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertTrue( $this->exception_was_thrown );
+	}
+
+	/**
+	 * When the request post title is not a valid email an error should be displayed.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_rejects_requests_with_bad_email_addresses() {
+		$request_id = wp_create_user_request( 'bad-email-requester@example.com', 'export_personal_data' );
+
+		wp_update_post(
+			array(
+				'ID'         => $request_id,
+				'post_title' => 'not-a-valid-email-address',
+			)
+		);
+
+		try {
+			$this->expectOutputString( '{"success":false,"data":"Invalid email address when generating export file."}' );
+			wp_privacy_generate_personal_data_export_file( $request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertTrue( $this->exception_was_thrown );
+	}
+
+	/**
+	 * When the export directory fails to be created an error should be displayed.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_detects_cannot_create_folder() {
+		$index_html_path = self::$exports_dir;
+		// Create a file with the folder name to ensure the function cannot create a folder.
+		touch( untrailingslashit( $index_html_path ) );
+
+		try {
+			$this->expectOutputString( '{"success":false,"data":"Unable to create export folder."}' );
+			wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertTrue( $this->exception_was_thrown );
+	}
+
+	/**
+	 * When the index.html file cannot be created an error should be displayed.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_detects_cannot_create_index() {
+		// Create and make the export directory read only so protection will fail.
+		mkdir( self::$exports_dir, 0444 );
+
+		try {
+			$this->expectOutputString( '{"success":false,"data":"Unable to protect export folder from browsing."}' );
+			wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertTrue( $this->exception_was_thrown );
+	}
+
+	/**
+	 * Test that an index.html file can be added to the export directory.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_creates_index_in_export_folder() {
+		try {
+			$this->expectOutputString( '' );
+			wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+		$index_html_path = self::$exports_dir . 'index.html';
+
+		$this->assertFalse( $this->exception_was_thrown );
+		$this->assertTrue( file_exists( $index_html_path ) );
+	}
+
+	/**
+	 * When the export directory is not writable the report should fail to write.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_detects_cannot_write_html() {
+		mkdir( self::$exports_dir );
+		$index_html_path = self::$exports_dir . 'index.html';
+		touch( $index_html_path );
+		chmod( self::$exports_dir, 0555 ); // Make the folder read only so html writing will fail.
+
+		try {
+			$this->expectOutputString( '{"success":false,"data":"Unable to open export file (HTML report) for writing."}' );
+			wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertTrue( $this->exception_was_thrown );
+		$this->assertEmpty( $this->export_file_name );
+	}
+
+
+	/**
+	 * Test that an export file is successfully created.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_can_succeed() {
+		try {
+			wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertFalse( $this->exception_was_thrown );
+		$this->assertTrue( file_exists( $this->export_file_name ) );
+	}
+
+	/**
+	 * Test the export file has all the expected parts.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_contents() {
+		try {
+			$this->expectOutputString( '' );
+			wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+		} catch ( Exception $e ) {
+			$this->exception_was_thrown = true;
+		}
+
+		$this->assertFalse( $this->exception_was_thrown );
+		$this->assertTrue( file_exists( $this->export_file_name ) );
+
+		$temp_dir = trailingslashit( self::$exports_dir . 'tempdir' );
+		mkdir( $temp_dir );
+		$zip = new ZipArchive;
+		$res = $zip->open( $this->export_file_name );
+
+		$this->assertTrue( $res );
+
+		$zip->extractTo( $temp_dir );
+		$zip->close();
+
+		$this->assertTrue( file_exists( $temp_dir . 'index.html' ) );
+
+		$report_contents = file_get_contents( $temp_dir . 'index.html' );
+
+		$this->assertContains( '<h1>Personal Data Export</h1>', $report_contents );
+		$this->assertContains( '<h2>About</h2>', $report_contents );
+
+		$request = wp_get_user_request_data( self::$export_request_id );
+		$this->assertContains( $request->email, $report_contents );
+	}
+}
diff --git tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php
new file mode 100644
index 0000000..3866e3e
--- /dev/null
+++ tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php
@@ -0,0 +1,771 @@
+<?php
+/**
+ * Test cases for the `wp_privacy_process_personal_data_export_page()` function.
+ *
+ * @package WordPress\UnitTests
+ * @since 4.9.7
+ */
+
+/**
+ * Tests_Privacy_WpPrivacyProcessPersonalDataExportPage class.
+ *
+ * @group privacy
+ * @covers wp_privacy_process_personal_data_export_page
+ *
+ * @since 4.9.7
+ */
+class Tests_Privacy_WpPrivacyProcessPersonalDataExportPage extends WP_UnitTestCase {
+	/**
+	 * Request ID.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $request_id
+	 */
+	protected static $request_id;
+
+	/**
+	 * Requester Email.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $request_email
+	 */
+	protected static $request_email;
+
+	/**
+	 * Response for the First Page.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var array $response
+	 */
+	protected static $response_first_page;
+
+	/**
+	 * Response for the Last Page.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var array $response_last_page
+	 */
+	protected static $response_last_page;
+
+	/**
+	 * Export File Url.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var string $export_file_url
+	 */
+	protected static $export_file_url;
+
+	/**
+	 * Requester Email.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var string $requester_email
+	 */
+	protected static $requester_email;
+
+	/**
+	 * Send As Email.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var bool $send_as_email
+	 */
+	protected static $send_as_email;
+
+	/**
+	 * Index Of The First Page.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $page
+	 */
+	protected static $page_index_first;
+
+	/**
+	 * Index Of The Last Page.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $page_index_last
+	 */
+	protected static $page_index_last;
+
+	/**
+	 * Index of the First Exporter.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $exporter_index_first
+	 */
+	protected static $exporter_index_first;
+
+	/**
+	 * Index of the Last Exporter.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $exporter_index_last
+	 */
+	protected static $exporter_index_last;
+
+	/**
+	 * Key of the First Exporter.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $exporter_key_first
+	 */
+	protected static $exporter_key_first;
+
+	/**
+	 * Key of the Last Exporter.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @var int $exporter_key_last
+	 */
+	protected static $exporter_key_last;
+
+	/**
+	 * Export data stored on the `wp_privacy_personal_data_export_file` action hook.
+	 *
+	 * @var string $_export_data_grouped_fetched_within_callback
+	 */
+	public $_export_data_grouped_fetched_within_callback;
+
+	/**
+	 * Setup before each test method.
+	 *
+	 * @since 4.9.7
+	 */
+	public function setUp() {
+		parent::setUp();
+
+		// Avoid writing export files to disk.
+		remove_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );
+
+		// Register our custom data exporters, very late, so we can override other unrelated exporters.
+		add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'filter_register_custom_personal_data_exporters' ), 9999 );
+
+		// Set ajax context for `wp_send_json()` and `wp_die()`.
+		add_filter( 'wp_doing_ajax', '__return_true' );
+
+		// Set up a `wp_die()` ajax handler that throws an exception, to be able to get
+		// the error message from `wp_send_json_error( 'some message here' )`,
+		// called by `wp_privacy_process_personal_data_export_page()`.
+		add_filter( 'wp_die_ajax_handler', array( $this, 'get_die_handler' ), 1, 1 );
+
+		// Suppress warnings from "Cannot modify header information - headers already sent by".
+		$this->_error_level = error_reporting();
+		error_reporting( $this->_error_level & ~E_WARNING );
+	}
+
+	/**
+	 * Clean up after each test method.
+	 *
+	 * @since 4.9.7
+	 */
+	public function tearDown() {
+		add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );
+
+		remove_filter( 'wp_privacy_personal_data_exporters', array( $this, 'filter_register_custom_personal_data_exporters' ), 9999 );
+		remove_filter( 'wp_doing_ajax', '__return_true' );
+		remove_filter( 'wp_die_ajax_handler', array( $this, 'get_die_handler' ), 1, 1 );
+		remove_filter( 'wp_mail_from', '__return_empty_string' );
+
+		error_reporting( $this->_error_level );
+
+		parent::tearDown();
+	}
+
+	/**
+	 * Return our die ajax callback handler.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @return callback
+	 */
+	public function get_die_handler() {
+		return array( $this, 'die_handler' );
+	}
+
+	/**
+	 * Ajax handler for `wp_die()`.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param string $message Message is empty in the ajax context.
+	 * @throws Exception Throws an exception, containing a message from the current output buffer.
+	 */
+	public function die_handler( $message ) {
+		throw new Exception( ob_get_clean() );
+	}
+
+	/**
+	 * Create user request fixtures shared by test methods.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param WP_UnitTest_Factory $factory Factory.
+	 */
+	public static function wpSetUpBeforeClass( $factory ) {
+		self::$requester_email      = 'requester@example.com';
+		self::$export_file_url      = wp_privacy_exports_url() . 'wp-personal-data-file-requester-at-example-com-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip';
+		$data                       = array(
+			array(
+				'group_id'    => 'custom-exporter-group-id',
+				'group_label' => 'custom-exporter-group-label',
+				'item_id'     => 'custom-exporter-item-id',
+				'data'        => array(
+					array(
+						'name'  => 'Email',
+						'value' => self::$requester_email,
+					),
+				),
+			),
+		);
+		self::$response_first_page  = array(
+			'done' => false,
+			'data' => $data,
+		);
+		self::$response_last_page   = array(
+			'done' => true,
+			'data' => $data,
+		);
+		self::$request_id           = wp_create_user_request( self::$requester_email, 'export_personal_data' );
+		self::$send_as_email        = true;
+		self::$page_index_first     = 1;
+		self::$page_index_last      = 2;
+		self::$exporter_index_first = 1;
+		self::$exporter_index_last  = 2;
+		self::$exporter_key_first   = 'custom-exporter-first';
+		self::$exporter_key_last    = 'custom-exporter-last';
+	}
+
+	/**
+	 * Filter to register custom personal data exporters.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param  array $exporters An array of personal data exporters.
+	 * @return array $exporters An array of personal data exporters.
+	 */
+	public function filter_register_custom_personal_data_exporters( $exporters ) {
+
+		// Let's override other unrelated exporters.
+		$exporters = array();
+
+		$exporters[ self::$exporter_key_first ] = array(
+			'exporter_friendly_name' => __( 'Custom Exporter #1' ),
+			'callback'               => null,
+		);
+		$exporters[ self::$exporter_key_last ]  = array(
+			'exporter_friendly_name' => __( 'Custom Exporter #2' ),
+			'callback'               => null,
+		);
+		return $exporters;
+	}
+
+	/**
+	 * The function should return the response when it's not an array.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_return_response_when_response_not_array() {
+		$response = 'not-an-array';
+		// Process data, given the last exporter, on the last page and send as email.
+		$actual_response = wp_privacy_process_personal_data_export_page(
+			$response,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( $response, $actual_response );
+	}
+
+	/**
+	 * The function should return the response when it's missing the 'done' array key.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_return_response_when_missing_done_array_key() {
+		$response = array(
+			'missing-done-array-key' => true,
+		);
+		// Process data, given the last exporter, on the last page and send as email.
+		$actual_response = wp_privacy_process_personal_data_export_page(
+			$response,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( $response, $actual_response );
+	}
+
+	/**
+	 * The function should return the response when it's missing the 'data' array key.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_return_response_when_missing_data_array_key() {
+		$response = array(
+			'done'                   => true,
+			'missing-data-array-key' => true,
+		);
+		// Process data, given the last exporter, on the last page and send as email.
+		$actual_response = wp_privacy_process_personal_data_export_page(
+			$response,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( $response, $actual_response );
+	}
+
+	/**
+	 * The function should return the response when data is not an array
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_return_response_when_data_not_array() {
+		$response = array(
+			'done' => true,
+			'data' => 'not-an-array',
+		);
+		// Process data, given the last exporter, on the last page and send as email.
+		$actual_response = wp_privacy_process_personal_data_export_page(
+			$response,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( $response, $actual_response );
+	}
+
+	/**
+	 * The function should send json error when invalid request ID.
+	 *
+	 * @since 4.9.7
+	 * @expectedException Exception
+	 * @expectedExceptionMessage {"success":false,"data":"Invalid request ID when merging exporter data."}
+	 */
+	public function test_function_should_send_error_when_invalid_request_id() {
+		$response   = array(
+			'done' => true,
+			'data' => array(),
+		);
+		$request_id = 0; // Invalid request ID.
+
+		// Process data, given the last exporter, on the last page and send as email.
+		ob_start();
+		wp_privacy_process_personal_data_export_page(
+			$response,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+	}
+
+	/**
+	 * The function should send json error when the request has an invalid action name.
+	 *
+	 * @since 4.9.7
+	 * @expectedException Exception
+	 * @expectedExceptionMessage {"success":false,"data":"Invalid request ID when merging exporter data."}
+	 */
+	public function test_function_should_send_error_when_invalid_request_action_name() {
+		$response = array(
+			'done' => true,
+			'data' => array(),
+		);
+		// A request with an invalid action name, 'export_personal_data' is expected.
+		$request_id = wp_create_user_request( self::$requester_email, 'remove_personal_data' );
+
+		// Process data, given the last exporter, on the last page and send as email.
+		ob_start();
+		wp_privacy_process_personal_data_export_page(
+			$response,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+	}
+
+	/**
+	 * The function should send json error on the last page of the last exporter when mail delivery fails.
+	 *
+	 * @since 4.9.7
+	 * @expectedException Exception
+	 * @expectedExceptionMessage {"success":false,"data":"Unable to send personal data export email."}
+	 */
+	public function test_function_should_send_error_on_last_page_of_last_exporter_when_mail_delivery_fails() {
+		// Cause `wp_mail()` to return false, to simulate mail delivery failure. Filter removed in tearDown.
+		add_filter( 'wp_mail_from', '__return_empty_string' );
+		// Process data, given the last exporter, on the last page and send as email.
+		ob_start();
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+	}
+
+	/**
+	 * The function should return the response, containing the export file url, when not sent as email
+	 * for the last exporter on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_return_response_with_export_file_url_when_not_sent_as_email_for_last_exporter_on_last_page() {
+		update_post_meta( self::$request_id, '_export_file_url', self::$export_file_url );
+
+		// Process data, given the last exporter, on the last page and not send as email.
+		$actual_response = wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_last
+		);
+
+		$this->assertArrayHasKey( 'url', $actual_response );
+		$this->assertSame( self::$export_file_url, $actual_response['url'] );
+		$this->assertSame( self::$response_last_page['done'], $actual_response['done'] );
+		$this->assertSame( self::$response_last_page['data'], $actual_response['data'] );
+	}
+
+	/**
+	 * The function should return the response containing the export file url when not sent as email
+	 * for the last exporter on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_return_response_without_export_file_url_when_sent_as_email_for_last_exporter_on_last_page() {
+		update_post_meta( self::$request_id, '_export_file_url', self::$export_file_url );
+
+		// Process data, given the last exporter, on the last page and send as email.
+		$actual_response = wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+
+		$this->assertArrayNotHasKey( 'url', $actual_response );
+		$this->assertSame( self::$response_last_page['done'], $actual_response['done'] );
+		$this->assertSame( self::$response_last_page['data'], $actual_response['data'] );
+	}
+
+	/**
+	 * The function should mark the request as completed for the last exporter on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_mark_request_as_completed_when_last_exporter_on_last_page() {
+		// Process data, given the last exporter on the last page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( 'request-completed', get_post_status( self::$request_id ) );
+
+		// Process data, given the last exporter on the last page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( 'request-completed', get_post_status( self::$request_id ) );
+	}
+
+	/**
+	 * The function should leave the request as pending when not the last exporter and not on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_leave_request_as_pending_when_not_last_exporter_and_not_on_last_page() {
+		// Process data, given the not last exporter, on the last page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
+
+		// Process data, given the not last exporter, on the last page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
+	}
+
+	/**
+	 * The function should leave the request as pending when last exporter and not on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_leave_request_as_pending_when_last_exporter_and_not_on_last_page() {
+		// Process data, given the last exporter, not on the last page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
+
+		// Process data, given the last exporter, not on the last page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
+	}
+
+	/**
+	 * The function should leave the request as pending when not last exporter on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_leave_request_as_pending_when_not_last_exporter_on_last_page() {
+		// Process data, given not the last exporter on the last page and sending as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
+
+		// Process data, given not the last exporter on the last page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertSame( 'request-pending', get_post_status( self::$request_id ) );
+	}
+
+	/**
+	 * The function should add `_export_data_raw` post meta for the request, when sent as email
+	 * for the first exporter on the first page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_add_post_meta_with_raw_data_when_sent_as_email_for_first_exporter_on_first_page() {
+		delete_post_meta( self::$request_id, '_export_data_raw' );
+		$this->assertEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+
+		// Process data, given the first exporter on the first page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertNotEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+	}
+
+	/**
+	 * The function should delete `_export_data_raw` post meta for the request, when sent as email
+	 * for the last exporter on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_delete_post_meta_with_raw_data_when_sent_as_email_for_last_exporter_and_last_page() {
+		// Adds post meta when processing data, given the first exporter on the first page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertNotEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+
+		// Deletes post meta when processing data, given the last exporter on the last page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+	}
+
+	/**
+	 * The function should add `_export_data_raw` post meta for the request, when first exporter and first page and
+	 * email is not sent.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_add_post_meta_with_raw_data_when_not_sent_as_email_for_first_exporter_and_first_page() {
+		$this->assertEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+		// Adds post meta when processing data, given the first exporter on the first page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertNotEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+
+	}
+
+	/**
+	 * The function should delete `_export_data_raw` post meta for the request, when sent as email
+	 * for the last exporter on the last page.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_delete_post_meta_with_raw_data_when_not_sent_as_email_for_last_exporter_and_last_page() {
+		// Adds post meta when processing data, given the first exporter on the first page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertNotEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+
+		// Deletes post meta when processing data, given the last exporter on the last page and not send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			! self::$send_as_email,
+			self::$exporter_key_last
+		);
+		$this->assertEmpty( get_post_meta( self::$request_id, '_export_data_raw', true ) );
+	}
+
+	/**
+	 * The function should add `_export_data_grouped` post meta for the request, only available when personal data export file is generated.
+	 *
+	 * @since 4.9.7
+	 */
+	public function test_function_should_add_post_meta_with_groups_data_only_available_when_export_file_generated() {
+		// Adds post meta when processing data, given the first exporter on the first page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_first_page,
+			self::$exporter_index_first,
+			self::$requester_email,
+			self::$page_index_first,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_first
+		);
+		$this->assertEmpty( get_post_meta( self::$request_id, '_export_data_grouped', true ) );
+
+		add_action( 'wp_privacy_personal_data_export_file', array( $this, 'action_callback_to_get_export_groups_data' ) );
+		// Process data, given the last exporter on the last page and send as email.
+		wp_privacy_process_personal_data_export_page(
+			self::$response_last_page,
+			self::$exporter_index_last,
+			self::$requester_email,
+			self::$page_index_last,
+			self::$request_id,
+			self::$send_as_email,
+			self::$exporter_key_last
+		);
+		remove_action( 'wp_privacy_personal_data_export_file', array( $this, 'action_callback_to_get_export_groups_data' ) );
+
+		$this->assertNotEmpty( $this->_export_data_grouped_fetched_within_callback );
+		$this->assertEmpty( get_post_meta( self::$request_id, '_export_data_grouped', true ) );
+	}
+
+	/**
+	 * A callback for the `wp_privacy_personal_data_export_file` action that stores the `_export_data_grouped` meta
+	 * data locally for testing.
+	 *
+	 * @since 4.9.7
+	 *
+	 * @param int $request_id Request ID.
+	 */
+	public function action_callback_to_get_export_groups_data( $request_id ) {
+		$this->_export_data_grouped_fetched_within_callback = get_post_meta( $request_id, '_export_data_grouped', true );
+	}
+}
