Skip to:
Content

BuddyPress.org

Changeset 7873


Ignore:
Timestamp:
02/14/2014 12:17:53 PM (10 years ago)
Author:
boonebgorges
Message:

Tests: xprofile factory create() methods should return IDs, not objects

This is more consistent with other components

Location:
trunk/tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/includes/factory.php

    r7521 r7873  
    114114    function create_object( $args ) {
    115115        $group_id = xprofile_insert_field_group( $args );
    116         return $this->get_object_by_id( $group_id );
     116        return $group_id;
    117117    }
    118118
     
    138138    function create_object( $args ) {
    139139        $field_id = xprofile_insert_field( $args );
    140         return $this->get_object_by_id( $field_id );
     140        return $field_id;
    141141    }
    142142
  • trunk/tests/testcases/xprofile/class-bp-xprofile-field.php

    r7419 r7873  
    1616        $group = $this->factory->xprofile_group->create();
    1717        $field = $this->factory->xprofile_field->create( array(
    18             'field_group_id' => $group->id,
     18            'field_group_id' => $group,
    1919            'type' => 'textbox',
    2020        ) );
    2121
    22         $f = new BP_XProfile_Field( $field->id );
     22        $f = new BP_XProfile_Field( $field );
    2323        $f->can_delete = 0;
    2424        $f->save();
    2525
    26         $f2 = new BP_XProfile_Field( $field->id );
     26        $f2 = new BP_XProfile_Field( $field );
    2727        $this->assertEquals( '0', $f2->can_delete );
    2828    }
  • trunk/tests/testcases/xprofile/class-bp-xprofile-profiledata.php

    r7835 r7873  
    1414        $f = $this->factory->xprofile_field->create( array(
    1515            'type' => 'textbox',
    16             'field_group_id' => $g->id,
    17         ) );
    18 
    19         $d = new BP_XProfile_ProfileData( $f->id, $u );
     16            'field_group_id' => $g,
     17        ) );
     18
     19        $d = new BP_XProfile_ProfileData( $f, $u );
    2020
    2121        $this->assertFalse( $d->exists() );
     
    3030        $f = $this->factory->xprofile_field->create( array(
    3131            'type' => 'textbox',
    32             'field_group_id' => $g->id,
    33         ) );
    34 
    35         xprofile_set_field_data( $f->id, $u, 'foo' );
    36 
    37         $d = new BP_XProfile_ProfileData( $f->id, $u );
    38 
    39         wp_cache_delete( $f->id, 'bp_xprofile_data_' . $u );
     32            'field_group_id' => $g,
     33        ) );
     34
     35        xprofile_set_field_data( $f, $u, 'foo' );
     36
     37        $d = new BP_XProfile_ProfileData( $f, $u );
     38
     39        wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
    4040
    4141        $this->assertTrue( $d->exists() );
     
    5050        $f = $this->factory->xprofile_field->create( array(
    5151            'type' => 'textbox',
    52             'field_group_id' => $g->id,
    53         ) );
    54         $d = new BP_XProfile_ProfileData( $f->id, $u );
     52            'field_group_id' => $g,
     53        ) );
     54        $d = new BP_XProfile_ProfileData( $f, $u );
    5555
    5656        // Fake the cache
    57         wp_cache_set( $f->id, 'foo', 'bp_xprofile_data_' . $u );
     57        wp_cache_set( $f, 'foo', 'bp_xprofile_data_' . $u );
    5858
    5959        $this->assertTrue( $d->exists() );
     
    6868        $f = $this->factory->xprofile_field->create( array(
    6969            'type' => 'textbox',
    70             'field_group_id' => $g->id,
     70            'field_group_id' => $g,
    7171        ) );
    7272
    7373        // Just to be sure
    74         wp_cache_delete( $f->id, 'bp_xprofile_data_' . $u );
    75 
    76         $this->assertEquals( 0, BP_XProfile_ProfileData::get_fielddataid_byid( $f->id, $u ) );
     74        wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     75
     76        $this->assertEquals( 0, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) );
    7777    }
    7878
     
    8585        $f = $this->factory->xprofile_field->create( array(
    8686            'type' => 'textbox',
    87             'field_group_id' => $g->id,
     87            'field_group_id' => $g,
    8888        ) );
    8989
    9090        $d = new BP_XProfile_ProfileData();
    9191        $d->user_id = $u;
    92         $d->field_id = $f->id;
     92        $d->field_id = $f;
    9393        $d->value = 'foo';
    9494        $d->save();
    9595
    9696        // Ensure it's deleted from cache
    97         wp_cache_delete( $f->id, 'bp_xprofile_data_' . $u );
    98 
    99         $this->assertEquals( $d->id, BP_XProfile_ProfileData::get_fielddataid_byid( $f->id, $u ) );
     97        wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     98
     99        $this->assertEquals( $d->id, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) );
    100100    }
    101101
     
    108108        $f = $this->factory->xprofile_field->create( array(
    109109            'type' => 'textbox',
    110             'field_group_id' => $g->id,
     110            'field_group_id' => $g,
    111111        ) );
    112112
     
    114114        $d = new stdClass;
    115115        $d->id = 5;
    116         wp_cache_set( $f->id, $d, 'bp_xprofile_data_' . $u );
    117 
    118         $this->assertSame( 5, BP_XProfile_ProfileData::get_fielddataid_byid( $f->id, $u ) );
     116        wp_cache_set( $f, $d, 'bp_xprofile_data_' . $u );
     117
     118        $this->assertSame( 5, BP_XProfile_ProfileData::get_fielddataid_byid( $f, $u ) );
    119119    }
    120120
     
    127127        $f = $this->factory->xprofile_field->create( array(
    128128            'type' => 'textbox',
    129             'field_group_id' => $g->id,
     129            'field_group_id' => $g,
    130130        ) );
    131131
    132132        $d = new BP_XProfile_ProfileData();
    133133        $d->user_id = $u;
    134         $d->field_id = $f->id;
     134        $d->field_id = $f;
    135135        $d->value = 'foo';
    136136        $d->save();
    137137
    138138        // Ensure it's deleted from cache
    139         wp_cache_delete( $f->id, 'bp_xprofile_data_' . $u );
    140 
    141         $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f->id, $u ) );
     139        wp_cache_delete( $f, 'bp_xprofile_data_' . $u );
     140
     141        $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f, $u ) );
    142142    }
    143143
     
    151151        $f = $this->factory->xprofile_field->create( array(
    152152            'type' => 'textbox',
    153             'field_group_id' => $g->id,
     153            'field_group_id' => $g,
    154154        ) );
    155155
     
    158158        $d1 = new BP_XProfile_ProfileData();
    159159        $d1->user_id = $u1;
    160         $d1->field_id = $f->id;
     160        $d1->field_id = $f;
    161161        $d1->value = 'foo';
    162162        $d1->last_updated = $time;
     
    165165        $d2 = new BP_XProfile_ProfileData();
    166166        $d2->user_id = $u2;
    167         $d2->field_id = $f->id;
     167        $d2->field_id = $f;
    168168        $d2->value = 'bar';
    169169        $d2->last_updated = $time;
     
    171171
    172172        // Ensure it's deleted from cache
    173         wp_cache_delete( $f->id, 'bp_xprofile_data_' . $u1 );
    174         wp_cache_delete( $f->id, 'bp_xprofile_data_' . $u2 );
     173        wp_cache_delete( $f, 'bp_xprofile_data_' . $u1 );
     174        wp_cache_delete( $f, 'bp_xprofile_data_' . $u2 );
    175175
    176176        $eu1 = new stdClass;
     
    178178        $eu1->value = 'foo';
    179179        $eu1->id = $d1->id;
    180         $eu1->field_id = $f->id;
     180        $eu1->field_id = $f;
    181181        $eu1->last_updated = $time;
    182182
     
    185185        $eu2->value = 'bar';
    186186        $eu2->id = $d2->id;
    187         $eu2->field_id = $f->id;
     187        $eu2->field_id = $f;
    188188        $eu2->last_updated = $time;
    189189
    190190        $expected = array( $eu1, $eu2 );
    191191
    192         $this->assertEquals( $expected, BP_XProfile_ProfileData::get_value_byid( $f->id, array( $u1, $u2 ) ) );
     192        $this->assertEquals( $expected, BP_XProfile_ProfileData::get_value_byid( $f, array( $u1, $u2 ) ) );
    193193    }
    194194
     
    201201        $f = $this->factory->xprofile_field->create( array(
    202202            'type' => 'textbox',
    203             'field_group_id' => $g->id,
     203            'field_group_id' => $g,
    204204        ) );
    205205
     
    209209        $d = new stdClass;
    210210        $d->value = 'foo';
    211         $d->field_id = $f->id;
    212         wp_cache_set( $f->id, $d, 'bp_xprofile_data_' . $u );
    213 
    214         $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f->id, $u ) );
     211        $d->field_id = $f;
     212        wp_cache_set( $f, $d, 'bp_xprofile_data_' . $u );
     213
     214        $this->assertSame( 'foo', BP_XProfile_ProfileData::get_value_byid( $f, $u ) );
    215215    }
    216216
     
    224224        $f = $this->factory->xprofile_field->create( array(
    225225            'type' => 'textbox',
    226             'field_group_id' => $g->id,
     226            'field_group_id' => $g,
    227227        ) );
    228228
     
    233233        $d1->id = 10;
    234234        $d1->user_id = $u1;
    235         $d1->field_id = $f->id;
     235        $d1->field_id = $f;
    236236        $d1->value = 'foo';
    237237        $d1->last_updated = $time;
     
    240240        $d1->id = 21;
    241241        $d2->user_id = $u2;
    242         $d2->field_id = $f->id;
     242        $d2->field_id = $f;
    243243        $d2->value = 'bar';
    244244        $d2->last_updated = $time;
    245245
    246         wp_cache_set( $f->id, $d1, 'bp_xprofile_data_' . $u1 );
    247         wp_cache_set( $f->id, $d2, 'bp_xprofile_data_' . $u2 );
     246        wp_cache_set( $f, $d1, 'bp_xprofile_data_' . $u1 );
     247        wp_cache_set( $f, $d2, 'bp_xprofile_data_' . $u2 );
    248248
    249249        $eu1 = new stdClass;
    250250        $eu1->id = 10;
    251251        $eu1->user_id = $u1;
    252         $eu1->field_id = $f->id;
     252        $eu1->field_id = $f;
    253253        $eu1->value = 'foo';
    254254        $eu1->last_updated = $time;
     
    257257        $eu1->id = 21;
    258258        $eu2->user_id = $u2;
    259         $eu2->field_id = $f->id;
     259        $eu2->field_id = $f;
    260260        $eu2->value = 'bar';
    261261        $eu2->last_updated = $time;
     
    263263        $expected = array( $eu1, $eu2 );
    264264
    265         $this->assertEquals( $expected, BP_XProfile_ProfileData::get_value_byid( $f->id, array( $u1, $u2 ) ) );
     265        $this->assertEquals( $expected, BP_XProfile_ProfileData::get_value_byid( $f, array( $u1, $u2 ) ) );
    266266    }
    267267
     
    275275        $f1 = $this->factory->xprofile_field->create( array(
    276276            'type' => 'textbox',
    277             'field_group_id' => $g1->id,
     277            'field_group_id' => $g1,
    278278        ) );
    279279        $f2 = $this->factory->xprofile_field->create( array(
    280280            'type' => 'radio',
    281             'field_group_id' => $g2->id,
     281            'field_group_id' => $g2,
    282282        ) );
    283283
     
    292292        $d1 = new BP_XProfile_ProfileData();
    293293        $d1->user_id = $u;
    294         $d1->field_id = $f1->id;
     294        $d1->field_id = $f1;
    295295        $d1->value = 'foo';
    296296        $d1->last_updated = $time;
     
    299299        $d2 = new BP_XProfile_ProfileData();
    300300        $d2->user_id = $u;
    301         $d2->field_id = $f2->id;
     301        $d2->field_id = $f2;
    302302        $d2->value = 'bar';
    303303        $d2->last_updated = $time;
     
    305305
    306306        // Ensure it's deleted from cache
    307         wp_cache_delete( $f1->id, 'bp_xprofile_data_' . $u );
    308         wp_cache_delete( $f2->id, 'bp_xprofile_data_' . $u );
     307        wp_cache_delete( $f1, 'bp_xprofile_data_' . $u );
     308        wp_cache_delete( $f2, 'bp_xprofile_data_' . $u );
    309309
    310310        $u_obj = new WP_User( $u );
     311
     312        $g1_obj = new BP_XProfile_Group( $g1 );
     313        $g2_obj = new BP_XProfile_Group( $g2 );
     314        $f1_obj = new BP_XProfile_Field( $f1 );
     315        $f2_obj = new BP_XProfile_Field( $f2 );
    311316
    312317        $expected = array(
     
    321326                'field_data' => $d0->value,
    322327            ),
    323             $f1->name => array(
    324                 'field_group_id' => $g1->id,
    325                 'field_group_name' => $g1->name,
    326                 'field_id' => $f1->id,
    327                 'field_type' => $f1->type,
     328            $f1_obj->name => array(
     329                'field_group_id' => $g1,
     330                'field_group_name' => $g1_obj->name,
     331                'field_id' => $f1,
     332                'field_type' => $f1_obj->type,
    328333                'field_data' => $d1->value,
    329334            ),
    330             $f2->name => array(
    331                 'field_group_id' => $g2->id,
    332                 'field_group_name' => $g2->name,
    333                 'field_id' => $f2->id,
    334                 'field_type' => $f2->type,
     335            $f2_obj->name => array(
     336                'field_group_id' => $g2,
     337                'field_group_name' => $g2_obj->name,
     338                'field_id' => $f2,
     339                'field_type' => $f2_obj->type,
    335340                'field_data' => $d2->value,
    336341            ),
     
    349354        $f1 = $this->factory->xprofile_field->create( array(
    350355            'type' => 'textbox',
    351             'field_group_id' => $g1->id,
     356            'field_group_id' => $g1,
    352357        ) );
    353358        $f2 = $this->factory->xprofile_field->create( array(
    354359            'type' => 'radio',
    355             'field_group_id' => $g2->id,
     360            'field_group_id' => $g2,
    356361        ) );
    357362
     
    364369        $d1 = new stdClass;
    365370        $d1->user_id = $u;
    366         $d1->field_id = $f1->id;
     371        $d1->field_id = $f1;
    367372        $d1->value = 'foo';
    368373        $d1->last_updated = $time;
     
    371376        $d2 = new stdClass;
    372377        $d2->user_id = $u;
    373         $d2->field_id = $f2->id;
     378        $d2->field_id = $f2;
    374379        $d2->value = 'bar';
    375380        $d2->last_updated = $time;
    376381        $d2->id = 2;
    377382
    378         wp_cache_set( $f1->id, $d1, 'bp_xprofile_data_' . $u );
    379         wp_cache_set( $f2->id, $d2, 'bp_xprofile_data_' . $u );
     383        wp_cache_set( $f1, $d1, 'bp_xprofile_data_' . $u );
     384        wp_cache_set( $f2, $d2, 'bp_xprofile_data_' . $u );
    380385
    381386        $u_obj = new WP_User( $u );
     387
     388        $g1_obj = new BP_XProfile_Group( $g1 );
     389        $g2_obj = new BP_XProfile_Group( $g2 );
     390        $f1_obj = new BP_XProfile_Field( $f1 );
     391        $f2_obj = new BP_XProfile_Field( $f2 );
    382392
    383393        $expected = array(
     
    392402                'field_data' => $d0->value,
    393403            ),
    394             $f1->name => array(
    395                 'field_group_id' => $g1->id,
    396                 'field_group_name' => $g1->name,
    397                 'field_id' => $f1->id,
    398                 'field_type' => $f1->type,
     404            $f1_obj->name => array(
     405                'field_group_id' => $g1,
     406                'field_group_name' => $g1_obj->name,
     407                'field_id' => $f1,
     408                'field_type' => $f1_obj->type,
    399409                'field_data' => $d1->value,
    400410            ),
    401             $f2->name => array(
    402                 'field_group_id' => $g2->id,
    403                 'field_group_name' => $g2->name,
    404                 'field_id' => $f2->id,
    405                 'field_type' => $f2->type,
     411            $f2_obj->name => array(
     412                'field_group_id' => $g2,
     413                'field_group_name' => $g2_obj->name,
     414                'field_id' => $f2,
     415                'field_type' => $f2_obj->type,
    406416                'field_data' => $d2->value,
    407417            ),
  • trunk/tests/testcases/xprofile/functions.php

    r7862 r7873  
    7171        $g = $this->factory->xprofile_group->create();
    7272        $f = $this->factory->xprofile_field->create( array(
    73             'field_group_id' => $g->id,
     73            'field_group_id' => $g,
    7474            'type' => 'textbox',
    7575        ) );
     
    7878
    7979Bar!';
    80         bp_xprofile_update_meta( $f->id, 'field', 'linebreak_field', $meta_value );
    81         $this->assertEquals( $meta_value, bp_xprofile_get_meta( $f->id, 'field', 'linebreak_field' ) );
     80        bp_xprofile_update_meta( $f, 'field', 'linebreak_field', $meta_value );
     81        $this->assertEquals( $meta_value, bp_xprofile_get_meta( $f, 'field', 'linebreak_field' ) );
    8282    }
    8383
     
    109109        $g = $this->factory->xprofile_group->create();
    110110        $f = $this->factory->xprofile_field->create( array(
    111             'field_group_id' => $g->id,
     111            'field_group_id' => $g,
    112112            'type' => 'textbox',
    113113        ) );
    114114
    115         bp_xprofile_update_meta( $f->id, 'field', 'default_visibility', 'adminsonly' );
    116         bp_xprofile_update_meta( $f->id, 'field', 'allow_custom_visibility', 'allowed' );
    117 
    118         xprofile_set_field_visibility_level( $f->id, $u, 'loggedin' );
    119 
    120         $this->assertSame( 'loggedin', xprofile_get_field_visibility_level( $f->id, $u ) );
     115        bp_xprofile_update_meta( $f, 'field', 'default_visibility', 'adminsonly' );
     116        bp_xprofile_update_meta( $f, 'field', 'allow_custom_visibility', 'allowed' );
     117
     118        xprofile_set_field_visibility_level( $f, $u, 'loggedin' );
     119
     120        $this->assertSame( 'loggedin', xprofile_get_field_visibility_level( $f, $u ) );
    121121    }
    122122
     
    128128        $g = $this->factory->xprofile_group->create();
    129129        $f = $this->factory->xprofile_field->create( array(
    130             'field_group_id' => $g->id,
     130            'field_group_id' => $g,
    131131            'type' => 'textbox',
    132132        ) );
    133133
    134         bp_xprofile_update_meta( $f->id, 'field', 'default_visibility', 'adminsonly' );
    135         bp_xprofile_update_meta( $f->id, 'field', 'allow_custom_visibility', 'allowed' );
    136 
    137         $this->assertSame( 'adminsonly', xprofile_get_field_visibility_level( $f->id, $u ) );
     134        bp_xprofile_update_meta( $f, 'field', 'default_visibility', 'adminsonly' );
     135        bp_xprofile_update_meta( $f, 'field', 'allow_custom_visibility', 'allowed' );
     136
     137        $this->assertSame( 'adminsonly', xprofile_get_field_visibility_level( $f, $u ) );
    138138
    139139    }
     
    146146        $g = $this->factory->xprofile_group->create();
    147147        $f = $this->factory->xprofile_field->create( array(
    148             'field_group_id' => $g->id,
     148            'field_group_id' => $g,
    149149            'type' => 'textbox',
    150150        ) );
    151151
    152         bp_xprofile_update_meta( $f->id, 'field', 'default_visibility', 'adminsonly' );
    153         bp_xprofile_update_meta( $f->id, 'field', 'allow_custom_visibility', 'disabled' );
    154 
    155         xprofile_set_field_visibility_level( $f->id, $u, 'loggedin' );
    156 
    157         $this->assertSame( 'adminsonly', xprofile_get_field_visibility_level( $f->id, $u ) );
     152        bp_xprofile_update_meta( $f, 'field', 'default_visibility', 'adminsonly' );
     153        bp_xprofile_update_meta( $f, 'field', 'allow_custom_visibility', 'disabled' );
     154
     155        xprofile_set_field_visibility_level( $f, $u, 'loggedin' );
     156
     157        $this->assertSame( 'adminsonly', xprofile_get_field_visibility_level( $f, $u ) );
    158158    }
    159159
     
    188188    public function test_bp_xprofile_delete_meta_illegal_characters() {
    189189        $g = $this->factory->xprofile_group->create();
    190         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    191         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     190        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     191        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    192192
    193193        $krazy_key = ' f!@#$%^o *(){}o?+';
    194         $this->assertTrue( bp_xprofile_delete_meta( $g->id, 'group', 'foo' ) );
    195         $this->assertEquals( '', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     194        $this->assertTrue( bp_xprofile_delete_meta( $g, 'group', 'foo' ) );
     195        $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    196196    }
    197197
     
    202202    public function test_bp_xprofile_delete_meta_trim_meta_value() {
    203203        $g = $this->factory->xprofile_group->create();
    204         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    205         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    206 
    207         $this->assertTrue( bp_xprofile_delete_meta( $g->id, 'group', 'foo', ' bar  ' ) );
    208         $this->assertEquals( '', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     204        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     205        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     206
     207        $this->assertTrue( bp_xprofile_delete_meta( $g, 'group', 'foo', ' bar  ' ) );
     208        $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    209209    }
    210210
     
    215215    public function test_bp_xprofile_delete_meta_meta_value_match() {
    216216        $g = $this->factory->xprofile_group->create();
    217         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    218         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    219         $this->assertTrue( bp_xprofile_delete_meta( $g->id, 'group', 'foo', 'bar' ) );
    220         $this->assertEquals( '', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     217        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     218        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     219        $this->assertTrue( bp_xprofile_delete_meta( $g, 'group', 'foo', 'bar' ) );
     220        $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    221221    }
    222222
     
    227227    public function test_bp_xprofile_delete_meta_delete_all() {
    228228        $g = $this->factory->xprofile_group->create();
    229         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    230         bp_xprofile_update_meta( $g->id, 'group', 'foo2', 'bar' );
    231         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    232         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo2' ) );
    233 
    234         $this->assertTrue( bp_xprofile_delete_meta( $g->id, 'group' ) );
     229        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     230        bp_xprofile_update_meta( $g, 'group', 'foo2', 'bar' );
     231        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     232        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo2' ) );
     233
     234        $this->assertTrue( bp_xprofile_delete_meta( $g, 'group' ) );
    235235
    236236        // These will fail because of a caching bug
    237         $this->assertEquals( '', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    238         $this->assertEquals( '', bp_xprofile_get_meta( $g->id, 'group', 'foo2' ) );
     237        $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     238        $this->assertEquals( '', bp_xprofile_get_meta( $g, 'group', 'foo2' ) );
    239239    }
    240240
     
    269269    public function test_bp_xprofile_get_meta_no_meta_key() {
    270270        $g = $this->factory->xprofile_group->create();
    271         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    272         bp_xprofile_update_meta( $g->id, 'group', 'foo2', 'bar' );
     271        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     272        bp_xprofile_update_meta( $g, 'group', 'foo2', 'bar' );
    273273
    274274        $expected = array( 'bar', 'bar', );
    275         $this->assertSame( $expected, bp_xprofile_get_meta( $g->id, 'group' ) );
     275        $this->assertSame( $expected, bp_xprofile_get_meta( $g, 'group' ) );
    276276    }
    277277
     
    284284
    285285        $expected = array();
    286         $this->assertSame( $expected, bp_xprofile_get_meta( $g->id, 'group' ) );
     286        $this->assertSame( $expected, bp_xprofile_get_meta( $g, 'group' ) );
    287287    }
    288288
     
    318318        $g = $this->factory->xprofile_group->create();
    319319        $krazy_key = ' f!@#$%^o *(){}o?+';
    320         bp_xprofile_update_meta( $g->id, 'group', $krazy_key, 'bar' );
    321         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     320        bp_xprofile_update_meta( $g, 'group', $krazy_key, 'bar' );
     321        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    322322    }
    323323
     
    329329        $g = $this->factory->xprofile_group->create();
    330330        $v = "Totally \'tubular\'";
    331         bp_xprofile_update_meta( $g->id, 'group', 'foo', $v );
    332         $this->assertSame( stripslashes( $v ), bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     331        bp_xprofile_update_meta( $g, 'group', 'foo', $v );
     332        $this->assertSame( stripslashes( $v ), bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    333333    }
    334334
     
    339339    public function test_bp_xprofile_update_meta_empty_value_delete() {
    340340        $g = $this->factory->xprofile_group->create();
    341         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    342         bp_xprofile_update_meta( $g->id, 'group', 'foo', '' );
    343         $this->assertSame( '', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     341        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     342        bp_xprofile_update_meta( $g, 'group', 'foo', '' );
     343        $this->assertSame( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    344344    }
    345345
     
    350350    public function test_bp_xprofile_update_meta_new() {
    351351        $g = $this->factory->xprofile_group->create();
    352         $this->assertSame( '', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    353         $this->assertTrue( bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' ) );
    354         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     352        $this->assertSame( '', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     353        $this->assertTrue( bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' ) );
     354        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    355355    }
    356356
     
    361361    public function test_bp_xprofile_update_meta_existing() {
    362362        $g = $this->factory->xprofile_group->create();
    363         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    364         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    365         $this->assertTrue( bp_xprofile_update_meta( $g->id, 'group', 'foo', 'baz' ) );
    366         $this->assertSame( 'baz', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
     363        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     364        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     365        $this->assertTrue( bp_xprofile_update_meta( $g, 'group', 'foo', 'baz' ) );
     366        $this->assertSame( 'baz', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
    367367    }
    368368
     
    373373    public function test_bp_xprofile_update_meta_same_value() {
    374374        $g = $this->factory->xprofile_group->create();
    375         bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' );
    376         $this->assertSame( 'bar', bp_xprofile_get_meta( $g->id, 'group', 'foo' ) );
    377         $this->assertFalse( bp_xprofile_update_meta( $g->id, 'group', 'foo', 'bar' ) );
     375        bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' );
     376        $this->assertSame( 'bar', bp_xprofile_get_meta( $g, 'group', 'foo' ) );
     377        $this->assertFalse( bp_xprofile_update_meta( $g, 'group', 'foo', 'bar' ) );
    378378    }
    379379}
Note: See TracChangeset for help on using the changeset viewer.