Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/23/2018 01:40:06 AM (8 years ago)
Author:
boonebgorges
Message:

Privacy: Data exporter for XProfile.

See #7817.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/functions.php

    r11737 r12110  
    10751075                unset( $GLOBALS['field'] );
    10761076        }
     1077
     1078        /**
     1079         * @ticket BP7817
     1080         * @ticket BP7698
     1081         */
     1082        public function test_bp_xprofile_personal_data_exporter() {
     1083                $u = self::factory()->user->create();
     1084
     1085                $field_group_id = self::factory()->xprofile_group->create();
     1086                $f1 = self::factory()->xprofile_field->create(
     1087                        array(
     1088                                'field_group_id' => $field_group_id,
     1089                        )
     1090                );
     1091                $f2 = self::factory()->xprofile_field->create(
     1092                        array(
     1093                                'field_group_id' => $field_group_id,
     1094                                'type'           => 'checkbox',
     1095                        )
     1096                );
     1097
     1098                $option1 = xprofile_insert_field( array(
     1099                        'field_group_id' => $field_group_id,
     1100                        'parent_id'      => $f2,
     1101                        'type'           => 'option',
     1102                        'name'           => 'Option 1',
     1103                ) );
     1104
     1105                $option2 = xprofile_insert_field( array(
     1106                        'field_group_id' => $field_group_id,
     1107                        'parent_id'      => $f2,
     1108                        'type'           => 'option',
     1109                        'name'           => 'Option 2',
     1110                ) );
     1111
     1112                $option3 = xprofile_insert_field( array(
     1113                        'field_group_id' => $field_group_id,
     1114                        'parent_id'      => $f2,
     1115                        'type'           => 'option',
     1116                        'name'           => 'Option 3',
     1117                ) );
     1118
     1119                xprofile_set_field_data( $f1, $u, 'foo' );
     1120                xprofile_set_field_data( $f2, $u, array( 'Option 1', 'Option 3' ) );
     1121
     1122                $test_user = new WP_User( $u );
     1123
     1124                $actual = bp_xprofile_personal_data_exporter( $test_user->user_email );
     1125
     1126                $this->assertTrue( $actual['done'] );
     1127
     1128                // Number of exported users.
     1129                $this->assertSame( 1, count( $actual['data'] ) );
     1130
     1131                // Number of exported user properties.
     1132                $this->assertSame( 3, count( $actual['data'][0]['data'] ) );
     1133        }
    10771134}
Note: See TracChangeset for help on using the changeset viewer.