Changeset 46209
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/privacy-tools.php
r45932 r46209 235 235 */ 236 236 function wp_privacy_generate_personal_data_export_group_html( $group_data ) { 237 $group_html = '<h2>' . esc_html( $group_data['group_label'] ) . '</h2>'; 237 $group_html = '<h2>'; 238 $group_html .= esc_html( $group_data['group_label'] ); 239 240 $items_count = count( (array) $group_data['items'] ); 241 if ( $items_count > 1 ) { 242 $group_html .= sprintf( ' <span class="count">(%d)</span>', $items_count ); 243 } 244 245 $group_html .= '</h2>'; 238 246 239 247 if ( ! empty( $group_data['group_description'] ) ) { -
trunk/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php
r44824 r46209 51 51 * 52 52 * @ticket 44044 53 * @ticket 46895 Updated to remove </h2> from test to avoid Count introducing failure. 53 54 */ 54 55 public function test_group_html_generation_multiple_data_items() { … … 81 82 $actual = wp_privacy_generate_personal_data_export_group_html( $data ); 82 83 83 $this->assertContains( '<h2>Test Data Group </h2>', $actual );84 $this->assertContains( '<h2>Test Data Group', $actual ); 84 85 $this->assertContains( '<td>Field 1 Value', $actual ); 85 86 $this->assertContains( '<td>Another Field 1 Value', $actual ); … … 198 199 $this->assertContains( '<th>Images are not allowed</th><td></td>', $actual ); 199 200 } 201 202 /** 203 * Test group count is displayed for multiple items. 204 * 205 * @ticket 46895 206 */ 207 public function test_group_html_generation_should_display_group_count_when_multiple_items() { 208 $data = array( 209 'group_label' => 'Test Data Group', 210 'items' => array( 211 array( 212 array( 213 'name' => 'Field 1 Name', 214 'value' => 'Field 1 Value', 215 ), 216 ), 217 array( 218 array( 219 'name' => 'Field 2 Name', 220 'value' => 'Field 2 Value', 221 ), 222 ), 223 ), 224 ); 225 226 $actual = wp_privacy_generate_personal_data_export_group_html( $data ); 227 228 $this->assertContains( '<h2>Test Data Group', $actual ); 229 $this->assertContains( '<span class="count">(2)</span></h2>', $actual ); 230 $this->assertSame( 2, substr_count( $actual, '<table>' ) ); 231 } 232 233 /** 234 * Test group count is not displayed for a single item. 235 * 236 * @ticket 46895 237 */ 238 public function test_group_html_generation_should_not_display_group_count_when_single_item() { 239 $data = array( 240 'group_label' => 'Test Data Group', 241 'items' => array( 242 array( 243 array( 244 'name' => 'Field 1 Name', 245 'value' => 'Field 1 Value', 246 ), 247 ), 248 ), 249 ); 250 251 $actual = wp_privacy_generate_personal_data_export_group_html( $data ); 252 253 $this->assertContains( '<h2>Test Data Group</h2>', $actual ); 254 $this->assertNotContains( '<span class="count">', $actual ); 255 $this->assertSame( 1, substr_count( $actual, '<table>' ) ); 256 } 200 257 }
Note: See TracChangeset
for help on using the changeset viewer.