', $report_contents );
+ $this->assertContains( $request->email, $report_contents );
+ }
+
+ /**
+ * Test the export HTML file containing multiple export groups with multiple group items
+ * has a table of contents with group count.
+ *
+ * @ticket 46894
+ */
+ public function test_multiple_group_export_multiple_items_group_count_in_toc() {
+ $this->expectOutputString( '' );
+
+ // Setup Export Data to contain multiple groups
+ $export_data_grouped = array(
+ 'user' => array(
+ 'group_label' => 'User',
+ 'group_description' => 'User’s profile data.',
+ 'items' => array(
+ 'user-1' => array(
+ array(
+ 'name' => 'User ID',
+ 'value' => 1,
+ ),
+ array(
+ 'name' => 'User Login Name',
+ 'value' => 'user_login',
+ ),
+ array(
+ 'name' => 'User Nice Name',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'User Email',
+ 'value' => 'export-requester@example.com',
+ ),
+ array(
+ 'name' => 'User Registration Date',
+ 'value' => '2020-01-31 19:29:29',
+ ),
+ array(
+ 'name' => 'User Display Name',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'User Nickname',
+ 'value' => 'User',
+ ),
+ ),
+ ),
+ ),
+ 'comments' => array(
+ 'group_label' => 'Comments',
+ 'group_description' => 'User’s comment data.',
+ 'items' => array(
+ 'comment-2' => array(
+ array(
+ 'name' => 'Comment Author',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'Comment Author Email',
+ 'value' => 'export-requester@example.com',
+ ),
+ array(
+ 'name' => 'Comment Author IP',
+ 'value' => '::1',
+ ),
+ array(
+ 'name' => 'Comment Author User Agent',
+ 'value' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
+ ),
+ array(
+ 'name' => 'Comment Date',
+ 'value' => '2020-01-31 19:55:19',
+ ),
+ array(
+ 'name' => 'Comment Content',
+ 'value' => 'Test',
+ ),
+ array(
+ 'name' => 'Comment URL',
+ 'value' => '
http://localhost:8888/46894/2020/01/31/hello-world/#comment-2',
+ ),
+ ),
+ 'comment-3' => array(
+ array(
+ 'name' => 'Comment Author',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'Comment Author Email',
+ 'value' => 'export-requester@example.com',
+ ),
+ array(
+ 'name' => 'Comment Author IP',
+ 'value' => '::1',
+ ),
+ array(
+ 'name' => 'Comment Author User Agent',
+ 'value' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
+ ),
+ array(
+ 'name' => 'Comment Date',
+ 'value' => '2020-01-31 20:55:19',
+ ),
+ array(
+ 'name' => 'Comment Content',
+ 'value' => 'Test #2',
+ ),
+ array(
+ 'name' => 'Comment URL',
+ 'value' => '
http://localhost:8888/46894/2020/01/31/hello-world/#comment-3',
+ ),
+ ),
+ ),
+ ),
+ );
+ update_post_meta( self::$export_request_id, '_export_data_grouped', $export_data_grouped );
+
+ // Generate Export File
+ wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+ $this->assertTrue( file_exists( $this->export_file_name ) );
+
+ // Cleam-up for subsequent tests
+ update_post_meta( self::$export_request_id, '_export_data_grouped', array() );
+
+ $report_dir = trailingslashit( self::$exports_dir . 'test_contents' );
+ mkdir( $report_dir );
+
+ $zip = new ZipArchive();
+ $opened_zip = $zip->open( $this->export_file_name );
+ $this->assertTrue( $opened_zip );
+
+ $zip->extractTo( $report_dir );
+ $zip->close();
+ $this->assertTrue( file_exists( $report_dir . 'index.html' ) );
+
+ $report_contents = file_get_contents( $report_dir . 'index.html' );
+ $request = wp_get_user_request( self::$export_request_id );
+
+ $this->assertContains( '
', $report_contents );
+ $this->assertContains( '
Comments (2)', $report_contents );
+ $this->assertContains( $request->email, $report_contents );
+ }
+
+ /**
+ * Test the export HTML file containing multiple export groups with no multiple group items
+ * has a table of contents without group count.
+ *
+ * @ticket 46894
+ */
+ public function test_multiple_group_export_single_items_no_group_count_in_toc() {
+ $this->expectOutputString( '' );
+
+ // Setup Export Data to contain multiple groups
+ $export_data_grouped = array(
+ 'user' => array(
+ 'group_label' => 'User',
+ 'group_description' => 'User’s profile data.',
+ 'items' => array(
+ 'user-1' => array(
+ array(
+ 'name' => 'User ID',
+ 'value' => 1,
+ ),
+ array(
+ 'name' => 'User Login Name',
+ 'value' => 'user_login',
+ ),
+ array(
+ 'name' => 'User Nice Name',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'User Email',
+ 'value' => 'export-requester@example.com',
+ ),
+ array(
+ 'name' => 'User Registration Date',
+ 'value' => '2020-01-31 19:29:29',
+ ),
+ array(
+ 'name' => 'User Display Name',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'User Nickname',
+ 'value' => 'User',
+ ),
+ ),
+ ),
+ ),
+ 'comments' => array(
+ 'group_label' => 'Comments',
+ 'group_description' => 'User’s comment data.',
+ 'items' => array(
+ 'comment-2' => array(
+ array(
+ 'name' => 'Comment Author',
+ 'value' => 'User Name',
+ ),
+ array(
+ 'name' => 'Comment Author Email',
+ 'value' => 'export-requester@example.com',
+ ),
+ array(
+ 'name' => 'Comment Author IP',
+ 'value' => '::1',
+ ),
+ array(
+ 'name' => 'Comment Author User Agent',
+ 'value' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36',
+ ),
+ array(
+ 'name' => 'Comment Date',
+ 'value' => '2020-01-31 19:55:19',
+ ),
+ array(
+ 'name' => 'Comment Content',
+ 'value' => 'Test',
+ ),
+ array(
+ 'name' => 'Comment URL',
+ 'value' => '
http://localhost:8888/46894/2020/01/31/hello-world/#comment-2',
+ ),
+ ),
+ ),
+ ),
+ );
+ update_post_meta( self::$export_request_id, '_export_data_grouped', $export_data_grouped );
+
+ // Generate Export File
+ wp_privacy_generate_personal_data_export_file( self::$export_request_id );
+ $this->assertTrue( file_exists( $this->export_file_name ) );
+
+ // Cleam-up for subsequent tests
+ update_post_meta( self::$export_request_id, '_export_data_grouped', array() );
+
+ $report_dir = trailingslashit( self::$exports_dir . 'test_contents' );
+ mkdir( $report_dir );
+
+ $zip = new ZipArchive();
+ $opened_zip = $zip->open( $this->export_file_name );
+ $this->assertTrue( $opened_zip );
+
+ $zip->extractTo( $report_dir );
+ $zip->close();
+ $this->assertTrue( file_exists( $report_dir . 'index.html' ) );
+
+ $report_contents = file_get_contents( $report_dir . 'index.html' );
+ $request = wp_get_user_request( self::$export_request_id );
+
+ $this->assertContains( '
', $report_contents );
+ $this->assertNotContains( '
', $report_contents );
+ $this->assertContains( $request->email, $report_contents );
+
+ }
}
diff --git a/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php b/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php
index 688f790e22..de721ab451 100644
--- a/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php
+++ b/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php
@@ -39,10 +39,10 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
$expected_table_markup = 'Field 1 Name | Field 1 Value |
---|
Field 2 Name | Field 2 Value |
---|
';
- $this->assertContains( 'Test Data Group
', $actual );
+ $this->assertContains( 'Test Data Group
', $actual );
$this->assertContains( $expected_table_markup, $actual );
}
@@ -79,9 +79,9 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
- $this->assertContains( 'Test Data Group', $actual );
+ $this->assertContains( 'Test Data Group', $actual );
$this->assertContains( 'Field 1 Value', $actual );
$this->assertContains( ' | Another Field 1 Value', $actual );
$this->assertContains( ' | Field 2 Value', $actual );
@@ -117,7 +117,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
$this->assertContains( 'http://wordpress.org', $actual );
$this->assertContains( 'https://wordpress.org', $actual );
@@ -131,13 +131,13 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
*/
public function test_group_labels_escaped() {
$data = array(
- 'group_label' => ' Escape HTML in group lavels ',
+ 'group_label' => 'Escape HTML in group labels ',
'items' => array(),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'escape-html-in-group-labels', 2 );
- $this->assertContains( '<div>Escape HTML in group lavels</div>', $actual );
+ $this->assertContains( '<div>Escape HTML in group labels</div>', $actual );
}
/**
@@ -162,8 +162,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
-
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
$this->assertContains( $data['items'][0]['links']['value'], $actual );
$this->assertContains( $data['items'][0]['formatting']['value'], $actual );
}
@@ -190,7 +189,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
$this->assertNotContains( $data['items'][0]['scripts']['value'], $actual );
$this->assertContains( ' | Testing that script tags are stripped. | ', $actual );
@@ -223,9 +222,9 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
- $this->assertContains( 'Test Data Group', $actual );
+ $this->assertContains( 'Test Data Group', $actual );
$this->assertContains( '(2)
', $actual );
$this->assertSame( 2, substr_count( $actual, '
' ) );
}
@@ -248,9 +247,9 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
),
);
- $actual = wp_privacy_generate_personal_data_export_group_html( $data );
+ $actual = wp_privacy_generate_personal_data_export_group_html( $data, 'test-data-group', 2 );
- $this->assertContains( 'Test Data Group
', $actual );
+ $this->assertContains( 'Test Data Group
', $actual );
$this->assertNotContains( '', $actual );
$this->assertSame( 1, substr_count( $actual, '