Make WordPress Core


Ignore:
Timestamp:
09/20/2019 08:29:30 PM (7 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/privacy/wpPrivacyGeneratePersonalDataExportGroupHtml.php

    r44824 r46209  
    5151         *
    5252         * @ticket 44044
     53         * @ticket 46895 Updated to remove </h2> from test to avoid Count introducing failure.
    5354         */
    5455        public function test_group_html_generation_multiple_data_items() {
     
    8182                $actual = wp_privacy_generate_personal_data_export_group_html( $data );
    8283
    83                 $this->assertContains( '<h2>Test Data Group</h2>', $actual );
     84                $this->assertContains( '<h2>Test Data Group', $actual );
    8485                $this->assertContains( '<td>Field 1 Value', $actual );
    8586                $this->assertContains( '<td>Another Field 1 Value', $actual );
     
    198199                $this->assertContains( '<th>Images are not allowed</th><td></td>', $actual );
    199200        }
     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        }
    200257}
Note: See TracChangeset for help on using the changeset viewer.