Changeset 7873
- Timestamp:
- 02/14/2014 12:17:53 PM (10 years ago)
- Location:
- trunk/tests
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/includes/factory.php
r7521 r7873 114 114 function create_object( $args ) { 115 115 $group_id = xprofile_insert_field_group( $args ); 116 return $ this->get_object_by_id( $group_id );116 return $group_id; 117 117 } 118 118 … … 138 138 function create_object( $args ) { 139 139 $field_id = xprofile_insert_field( $args ); 140 return $ this->get_object_by_id( $field_id );140 return $field_id; 141 141 } 142 142 -
trunk/tests/testcases/xprofile/class-bp-xprofile-field.php
r7419 r7873 16 16 $group = $this->factory->xprofile_group->create(); 17 17 $field = $this->factory->xprofile_field->create( array( 18 'field_group_id' => $group ->id,18 'field_group_id' => $group, 19 19 'type' => 'textbox', 20 20 ) ); 21 21 22 $f = new BP_XProfile_Field( $field ->id);22 $f = new BP_XProfile_Field( $field ); 23 23 $f->can_delete = 0; 24 24 $f->save(); 25 25 26 $f2 = new BP_XProfile_Field( $field ->id);26 $f2 = new BP_XProfile_Field( $field ); 27 27 $this->assertEquals( '0', $f2->can_delete ); 28 28 } -
trunk/tests/testcases/xprofile/class-bp-xprofile-profiledata.php
r7835 r7873 14 14 $f = $this->factory->xprofile_field->create( array( 15 15 '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 ); 20 20 21 21 $this->assertFalse( $d->exists() ); … … 30 30 $f = $this->factory->xprofile_field->create( array( 31 31 '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 ); 40 40 41 41 $this->assertTrue( $d->exists() ); … … 50 50 $f = $this->factory->xprofile_field->create( array( 51 51 '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 ); 55 55 56 56 // Fake the cache 57 wp_cache_set( $f ->id, 'foo', 'bp_xprofile_data_' . $u );57 wp_cache_set( $f, 'foo', 'bp_xprofile_data_' . $u ); 58 58 59 59 $this->assertTrue( $d->exists() ); … … 68 68 $f = $this->factory->xprofile_field->create( array( 69 69 'type' => 'textbox', 70 'field_group_id' => $g ->id,70 'field_group_id' => $g, 71 71 ) ); 72 72 73 73 // 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 ) ); 77 77 } 78 78 … … 85 85 $f = $this->factory->xprofile_field->create( array( 86 86 'type' => 'textbox', 87 'field_group_id' => $g ->id,87 'field_group_id' => $g, 88 88 ) ); 89 89 90 90 $d = new BP_XProfile_ProfileData(); 91 91 $d->user_id = $u; 92 $d->field_id = $f ->id;92 $d->field_id = $f; 93 93 $d->value = 'foo'; 94 94 $d->save(); 95 95 96 96 // 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 ) ); 100 100 } 101 101 … … 108 108 $f = $this->factory->xprofile_field->create( array( 109 109 'type' => 'textbox', 110 'field_group_id' => $g ->id,110 'field_group_id' => $g, 111 111 ) ); 112 112 … … 114 114 $d = new stdClass; 115 115 $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 ) ); 119 119 } 120 120 … … 127 127 $f = $this->factory->xprofile_field->create( array( 128 128 'type' => 'textbox', 129 'field_group_id' => $g ->id,129 'field_group_id' => $g, 130 130 ) ); 131 131 132 132 $d = new BP_XProfile_ProfileData(); 133 133 $d->user_id = $u; 134 $d->field_id = $f ->id;134 $d->field_id = $f; 135 135 $d->value = 'foo'; 136 136 $d->save(); 137 137 138 138 // 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 ) ); 142 142 } 143 143 … … 151 151 $f = $this->factory->xprofile_field->create( array( 152 152 'type' => 'textbox', 153 'field_group_id' => $g ->id,153 'field_group_id' => $g, 154 154 ) ); 155 155 … … 158 158 $d1 = new BP_XProfile_ProfileData(); 159 159 $d1->user_id = $u1; 160 $d1->field_id = $f ->id;160 $d1->field_id = $f; 161 161 $d1->value = 'foo'; 162 162 $d1->last_updated = $time; … … 165 165 $d2 = new BP_XProfile_ProfileData(); 166 166 $d2->user_id = $u2; 167 $d2->field_id = $f ->id;167 $d2->field_id = $f; 168 168 $d2->value = 'bar'; 169 169 $d2->last_updated = $time; … … 171 171 172 172 // 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 ); 175 175 176 176 $eu1 = new stdClass; … … 178 178 $eu1->value = 'foo'; 179 179 $eu1->id = $d1->id; 180 $eu1->field_id = $f ->id;180 $eu1->field_id = $f; 181 181 $eu1->last_updated = $time; 182 182 … … 185 185 $eu2->value = 'bar'; 186 186 $eu2->id = $d2->id; 187 $eu2->field_id = $f ->id;187 $eu2->field_id = $f; 188 188 $eu2->last_updated = $time; 189 189 190 190 $expected = array( $eu1, $eu2 ); 191 191 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 ) ) ); 193 193 } 194 194 … … 201 201 $f = $this->factory->xprofile_field->create( array( 202 202 'type' => 'textbox', 203 'field_group_id' => $g ->id,203 'field_group_id' => $g, 204 204 ) ); 205 205 … … 209 209 $d = new stdClass; 210 210 $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 ) ); 215 215 } 216 216 … … 224 224 $f = $this->factory->xprofile_field->create( array( 225 225 'type' => 'textbox', 226 'field_group_id' => $g ->id,226 'field_group_id' => $g, 227 227 ) ); 228 228 … … 233 233 $d1->id = 10; 234 234 $d1->user_id = $u1; 235 $d1->field_id = $f ->id;235 $d1->field_id = $f; 236 236 $d1->value = 'foo'; 237 237 $d1->last_updated = $time; … … 240 240 $d1->id = 21; 241 241 $d2->user_id = $u2; 242 $d2->field_id = $f ->id;242 $d2->field_id = $f; 243 243 $d2->value = 'bar'; 244 244 $d2->last_updated = $time; 245 245 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 ); 248 248 249 249 $eu1 = new stdClass; 250 250 $eu1->id = 10; 251 251 $eu1->user_id = $u1; 252 $eu1->field_id = $f ->id;252 $eu1->field_id = $f; 253 253 $eu1->value = 'foo'; 254 254 $eu1->last_updated = $time; … … 257 257 $eu1->id = 21; 258 258 $eu2->user_id = $u2; 259 $eu2->field_id = $f ->id;259 $eu2->field_id = $f; 260 260 $eu2->value = 'bar'; 261 261 $eu2->last_updated = $time; … … 263 263 $expected = array( $eu1, $eu2 ); 264 264 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 ) ) ); 266 266 } 267 267 … … 275 275 $f1 = $this->factory->xprofile_field->create( array( 276 276 'type' => 'textbox', 277 'field_group_id' => $g1 ->id,277 'field_group_id' => $g1, 278 278 ) ); 279 279 $f2 = $this->factory->xprofile_field->create( array( 280 280 'type' => 'radio', 281 'field_group_id' => $g2 ->id,281 'field_group_id' => $g2, 282 282 ) ); 283 283 … … 292 292 $d1 = new BP_XProfile_ProfileData(); 293 293 $d1->user_id = $u; 294 $d1->field_id = $f1 ->id;294 $d1->field_id = $f1; 295 295 $d1->value = 'foo'; 296 296 $d1->last_updated = $time; … … 299 299 $d2 = new BP_XProfile_ProfileData(); 300 300 $d2->user_id = $u; 301 $d2->field_id = $f2 ->id;301 $d2->field_id = $f2; 302 302 $d2->value = 'bar'; 303 303 $d2->last_updated = $time; … … 305 305 306 306 // 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 ); 309 309 310 310 $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 ); 311 316 312 317 $expected = array( … … 321 326 'field_data' => $d0->value, 322 327 ), 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, 328 333 'field_data' => $d1->value, 329 334 ), 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, 335 340 'field_data' => $d2->value, 336 341 ), … … 349 354 $f1 = $this->factory->xprofile_field->create( array( 350 355 'type' => 'textbox', 351 'field_group_id' => $g1 ->id,356 'field_group_id' => $g1, 352 357 ) ); 353 358 $f2 = $this->factory->xprofile_field->create( array( 354 359 'type' => 'radio', 355 'field_group_id' => $g2 ->id,360 'field_group_id' => $g2, 356 361 ) ); 357 362 … … 364 369 $d1 = new stdClass; 365 370 $d1->user_id = $u; 366 $d1->field_id = $f1 ->id;371 $d1->field_id = $f1; 367 372 $d1->value = 'foo'; 368 373 $d1->last_updated = $time; … … 371 376 $d2 = new stdClass; 372 377 $d2->user_id = $u; 373 $d2->field_id = $f2 ->id;378 $d2->field_id = $f2; 374 379 $d2->value = 'bar'; 375 380 $d2->last_updated = $time; 376 381 $d2->id = 2; 377 382 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 ); 380 385 381 386 $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 ); 382 392 383 393 $expected = array( … … 392 402 'field_data' => $d0->value, 393 403 ), 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, 399 409 'field_data' => $d1->value, 400 410 ), 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, 406 416 'field_data' => $d2->value, 407 417 ), -
trunk/tests/testcases/xprofile/functions.php
r7862 r7873 71 71 $g = $this->factory->xprofile_group->create(); 72 72 $f = $this->factory->xprofile_field->create( array( 73 'field_group_id' => $g ->id,73 'field_group_id' => $g, 74 74 'type' => 'textbox', 75 75 ) ); … … 78 78 79 79 Bar!'; 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' ) ); 82 82 } 83 83 … … 109 109 $g = $this->factory->xprofile_group->create(); 110 110 $f = $this->factory->xprofile_field->create( array( 111 'field_group_id' => $g ->id,111 'field_group_id' => $g, 112 112 'type' => 'textbox', 113 113 ) ); 114 114 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 ) ); 121 121 } 122 122 … … 128 128 $g = $this->factory->xprofile_group->create(); 129 129 $f = $this->factory->xprofile_field->create( array( 130 'field_group_id' => $g ->id,130 'field_group_id' => $g, 131 131 'type' => 'textbox', 132 132 ) ); 133 133 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 ) ); 138 138 139 139 } … … 146 146 $g = $this->factory->xprofile_group->create(); 147 147 $f = $this->factory->xprofile_field->create( array( 148 'field_group_id' => $g ->id,148 'field_group_id' => $g, 149 149 'type' => 'textbox', 150 150 ) ); 151 151 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 ) ); 158 158 } 159 159 … … 188 188 public function test_bp_xprofile_delete_meta_illegal_characters() { 189 189 $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' ) ); 192 192 193 193 $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' ) ); 196 196 } 197 197 … … 202 202 public function test_bp_xprofile_delete_meta_trim_meta_value() { 203 203 $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' ) ); 209 209 } 210 210 … … 215 215 public function test_bp_xprofile_delete_meta_meta_value_match() { 216 216 $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' ) ); 221 221 } 222 222 … … 227 227 public function test_bp_xprofile_delete_meta_delete_all() { 228 228 $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' ) ); 235 235 236 236 // 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' ) ); 239 239 } 240 240 … … 269 269 public function test_bp_xprofile_get_meta_no_meta_key() { 270 270 $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' ); 273 273 274 274 $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' ) ); 276 276 } 277 277 … … 284 284 285 285 $expected = array(); 286 $this->assertSame( $expected, bp_xprofile_get_meta( $g ->id, 'group' ) );286 $this->assertSame( $expected, bp_xprofile_get_meta( $g, 'group' ) ); 287 287 } 288 288 … … 318 318 $g = $this->factory->xprofile_group->create(); 319 319 $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' ) ); 322 322 } 323 323 … … 329 329 $g = $this->factory->xprofile_group->create(); 330 330 $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' ) ); 333 333 } 334 334 … … 339 339 public function test_bp_xprofile_update_meta_empty_value_delete() { 340 340 $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' ) ); 344 344 } 345 345 … … 350 350 public function test_bp_xprofile_update_meta_new() { 351 351 $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' ) ); 355 355 } 356 356 … … 361 361 public function test_bp_xprofile_update_meta_existing() { 362 362 $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' ) ); 367 367 } 368 368 … … 373 373 public function test_bp_xprofile_update_meta_same_value() { 374 374 $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' ) ); 378 378 } 379 379 }
Note: See TracChangeset
for help on using the changeset viewer.