mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Privacy: Display group items count in the personal data export file if there's more than one item in the group.
Props birgire, garrett-eclipse, pputzer. Fixes #46895. git-svn-id: https://develop.svn.wordpress.org/trunk@46209 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -50,6 +50,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
|
||||
* Test when a multiple data items are passed.
|
||||
*
|
||||
* @ticket 44044
|
||||
* @ticket 46895 Updated to remove </h2> from test to avoid Count introducing failure.
|
||||
*/
|
||||
public function test_group_html_generation_multiple_data_items() {
|
||||
$data = array(
|
||||
@@ -80,7 +81,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
|
||||
|
||||
$actual = wp_privacy_generate_personal_data_export_group_html( $data );
|
||||
|
||||
$this->assertContains( '<h2>Test Data Group</h2>', $actual );
|
||||
$this->assertContains( '<h2>Test Data Group', $actual );
|
||||
$this->assertContains( '<td>Field 1 Value', $actual );
|
||||
$this->assertContains( '<td>Another Field 1 Value', $actual );
|
||||
$this->assertContains( '<td>Field 2 Value', $actual );
|
||||
@@ -197,4 +198,60 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportGroupHtml extends WP_Unit
|
||||
$this->assertNotContains( $data['items'][0]['images']['value'], $actual );
|
||||
$this->assertContains( '<th>Images are not allowed</th><td></td>', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test group count is displayed for multiple items.
|
||||
*
|
||||
* @ticket 46895
|
||||
*/
|
||||
public function test_group_html_generation_should_display_group_count_when_multiple_items() {
|
||||
$data = array(
|
||||
'group_label' => 'Test Data Group',
|
||||
'items' => array(
|
||||
array(
|
||||
array(
|
||||
'name' => 'Field 1 Name',
|
||||
'value' => 'Field 1 Value',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'Field 2 Name',
|
||||
'value' => 'Field 2 Value',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$actual = wp_privacy_generate_personal_data_export_group_html( $data );
|
||||
|
||||
$this->assertContains( '<h2>Test Data Group', $actual );
|
||||
$this->assertContains( '<span class="count">(2)</span></h2>', $actual );
|
||||
$this->assertSame( 2, substr_count( $actual, '<table>' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test group count is not displayed for a single item.
|
||||
*
|
||||
* @ticket 46895
|
||||
*/
|
||||
public function test_group_html_generation_should_not_display_group_count_when_single_item() {
|
||||
$data = array(
|
||||
'group_label' => 'Test Data Group',
|
||||
'items' => array(
|
||||
array(
|
||||
array(
|
||||
'name' => 'Field 1 Name',
|
||||
'value' => 'Field 1 Value',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$actual = wp_privacy_generate_personal_data_export_group_html( $data );
|
||||
|
||||
$this->assertContains( '<h2>Test Data Group</h2>', $actual );
|
||||
$this->assertNotContains( '<span class="count">', $actual );
|
||||
$this->assertSame( 1, substr_count( $actual, '<table>' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user