[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @group members 4 */ 5 class BP_Tests_Members_Functions extends BP_UnitTestCase { 6 7 /** 8 * @ticket BP4915 9 * @group bp_core_delete_account 10 */ 11 public function test_bp_core_delete_account() { 12 // Stash 13 $current_user = get_current_user_id(); 14 $deletion_disabled = bp_disable_account_deletion(); 15 16 // Create an admin for testing 17 $admin_user = self::factory()->user->create( array( 'role' => 'administrator' ) ); 18 $this->grant_super_admin( $admin_user ); 19 20 // 1. Admin can delete user account 21 $this->set_current_user( $admin_user ); 22 $user1 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 23 bp_core_delete_account( $user1 ); 24 $maybe_user = new WP_User( $user1 ); 25 $this->assertEquals( 0, $maybe_user->ID ); 26 unset( $maybe_user ); 27 $this->restore_admins(); 28 29 // 2. Admin cannot delete superadmin account 30 $user2 = self::factory()->user->create( array( 'role' => 'administrator' ) ); 31 $this->grant_super_admin( $user2 ); 32 bp_core_delete_account( $user2 ); 33 $maybe_user = new WP_User( $user2 ); 34 $this->assertNotEquals( 0, $maybe_user->ID ); 35 unset( $maybe_user ); 36 37 // User cannot delete other's account 38 $user3 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 39 $user4 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 40 $this->set_current_user( $user3 ); 41 bp_core_delete_account( $user4 ); 42 $maybe_user = new WP_User( $user4 ); 43 $this->assertNotEquals( 0, $maybe_user->ID ); 44 unset( $maybe_user ); 45 46 // Cleanup 47 $this->set_current_user( $current_user ); 48 bp_update_option( 'bp-disable-account-deletion', $deletion_disabled ); 49 } 50 51 /** 52 * @ticket BP8175 53 */ 54 public function test_last_activity_data_should_be_deleted_on_user_delete_non_multisite() { 55 if ( is_multisite() ) { 56 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 57 } 58 59 $u1 = self::factory()->user->create(); 60 61 $now = time(); 62 bp_update_user_last_activity( $u1, $now ); 63 64 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 65 66 wp_delete_user( $u1 ); 67 68 $this->assertEquals( '', bp_get_user_last_activity( $u1 ) ); 69 } 70 71 /** 72 * @ticket BP8175 73 */ 74 public function test_last_activity_data_should_be_deleted_on_user_delete_multisite() { 75 if ( ! is_multisite() ) { 76 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 77 } 78 79 $u1 = self::factory()->user->create(); 80 81 $now = time(); 82 bp_update_user_last_activity( $u1, $now ); 83 84 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 85 86 wpmu_delete_user( $u1 ); 87 88 $this->assertEquals( '', bp_get_user_last_activity( $u1 ) ); 89 } 90 91 /** 92 * @ticket BP8175 93 */ 94 public function test_last_activity_data_should_not_be_deleted_on_wp_delete_user_multisite() { 95 if ( ! is_multisite() ) { 96 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 97 } 98 99 $u1 = self::factory()->user->create(); 100 101 $now = time(); 102 bp_update_user_last_activity( $u1, $now ); 103 104 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 105 106 wp_delete_user( $u1 ); 107 108 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 109 } 110 111 /** 112 * @group object_cache 113 * @group bp_core_get_directory_pages 114 */ 115 public function test_bp_core_get_user_domain_after_directory_page_update() { 116 // Generate user 117 $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 118 119 // Set object cache first for user domain 120 $user_domain = bp_core_get_user_domain( $user_id ); 121 122 // Now change the members directory slug 123 $pages = bp_core_get_directory_pages(); 124 $members_page = get_post( $pages->members->id ); 125 $members_page->post_name = 'new-members-slug'; 126 wp_update_post( $members_page ); 127 128 // Go back to members directory page and recheck user domain 129 $this->go_to( trailingslashit( home_url( 'new-members-slug' ) ) ); 130 $user = new WP_User( $user_id ); 131 132 $this->assertSame( home_url( 'new-members-slug' ) . '/' . $user->user_nicename . '/', bp_core_get_user_domain( $user_id ) ); 133 } 134 135 /** 136 * @group bp_core_get_user_displayname 137 */ 138 public function test_bp_core_get_user_displayname_empty_username() { 139 $this->assertFalse( bp_core_get_user_displayname( '' ) ); 140 } 141 142 /** 143 * @group bp_core_get_user_displayname 144 */ 145 public function test_bp_core_get_user_displayname_translate_username() { 146 $u = self::factory()->user->create(); 147 148 $user = new WP_User( $u ); 149 150 $found = bp_core_get_user_displayname( $u ); 151 $this->assertNotEmpty( $found ); 152 $this->assertSame( $found, bp_core_get_user_displayname( $user->user_login ) ); 153 } 154 155 /** 156 * @group bp_core_get_user_displayname 157 */ 158 public function test_bp_core_get_user_displayname_bad_username() { 159 $this->assertFalse( bp_core_get_user_displayname( 'i_dont_exist' ) ); 160 } 161 162 /** 163 * @group bp_core_get_user_displayname 164 */ 165 public function test_bp_core_get_user_displayname_xprofile_exists() { 166 $xprofile_is_active = bp_is_active( 'xprofile' ); 167 buddypress()->active_components['xprofile'] = '1'; 168 169 $u = self::factory()->user->create(); 170 xprofile_set_field_data( 1, $u, 'Foo Foo' ); 171 172 $this->assertSame( 'Foo Foo', bp_core_get_user_displayname( $u ) ); 173 174 if ( ! $xprofile_is_active ) { 175 unset( buddypress()->active_components['xprofile'] ); 176 } 177 } 178 179 /** 180 * @group bp_core_get_user_displaynames 181 */ 182 public function test_bp_core_get_user_displayname_arrays_all_bad_entries() { 183 $this->assertSame( array(), bp_core_get_user_displaynames( array( 0, 'foo', ) ) ); 184 } 185 186 /** 187 * @group bp_core_get_user_displaynames 188 */ 189 public function test_bp_core_get_user_displaynames_all_uncached() { 190 $u1 = self::factory()->user->create(); 191 $u2 = self::factory()->user->create(); 192 xprofile_set_field_data( 1, $u1, 'Foo' ); 193 xprofile_set_field_data( 1, $u2, 'Bar' ); 194 195 $expected = array( 196 $u1 => 'Foo', 197 $u2 => 'Bar', 198 ); 199 200 $this->assertSame( $expected, bp_core_get_user_displaynames( array( $u1, $u2, ) ) ); 201 } 202 203 /** 204 * @group bp_core_get_user_displaynames 205 */ 206 public function test_bp_core_get_user_displaynames_one_not_in_xprofile() { 207 $u1 = self::factory()->user->create(); 208 $u2 = self::factory()->user->create( array( 209 'display_name' => 'Bar', 210 ) ); 211 xprofile_set_field_data( 1, $u1, 'Foo' ); 212 213 $expected = array( 214 $u1 => 'Foo', 215 $u2 => 'Bar', 216 ); 217 218 $this->assertSame( $expected, bp_core_get_user_displaynames( array( $u1, $u2, ) ) ); 219 } 220 221 /** 222 * @group bp_members_migrate_signups 223 */ 224 public function test_bp_members_migrate_signups_standard() { 225 $u = self::factory()->user->create(); 226 $u_obj = new WP_User( $u ); 227 228 // Fake an old-style registration 229 $key = wp_generate_password( 32, false ); 230 update_user_meta( $u, 'activation_key', $key ); 231 232 global $wpdb; 233 $wpdb->update( 234 $wpdb->users, 235 array( 'user_status' => '2', ), 236 array( 'ID' => $u, ), 237 array( '%d', ), 238 array( '%d', ) 239 ); 240 clean_user_cache( $u ); 241 242 bp_members_migrate_signups(); 243 244 $found = BP_Signup::get(); 245 246 // Use email address as a sanity check 247 $found_email = isset( $found['signups'][0]->user_email ) ? $found['signups'][0]->user_email : ''; 248 $this->assertSame( $u_obj->user_email, $found_email ); 249 250 // Check that activation keys match 251 $found_key = isset( $found['signups'][0]->activation_key ) ? $found['signups'][0]->activation_key : ''; 252 $this->assertSame( $key, $found_key ); 253 } 254 255 /** 256 * @group bp_members_migrate_signups 257 */ 258 public function test_bp_members_migrate_signups_activation_key_but_user_status_0() { 259 $u = self::factory()->user->create(); 260 $u_obj = new WP_User( $u ); 261 262 // Fake an old-style registration 263 $key = wp_generate_password( 32, false ); 264 update_user_meta( $u, 'activation_key', $key ); 265 266 // ...but ensure that user_status is 0. This mimics the 267 // behavior of certain plugins that disrupt the BP registration 268 // flow 269 global $wpdb; 270 $wpdb->update( 271 $wpdb->users, 272 array( 'user_status' => '0', ), 273 array( 'ID' => $u, ), 274 array( '%d', ), 275 array( '%d', ) 276 ); 277 clean_user_cache( $u ); 278 279 bp_members_migrate_signups(); 280 281 // No migrations should have taken place 282 $found = BP_Signup::get(); 283 $this->assertEmpty( $found['total'] ); 284 } 285 286 /** 287 * @group bp_members_migrate_signups 288 */ 289 public function test_bp_members_migrate_signups_no_activation_key_but_user_status_2() { 290 $u = self::factory()->user->create(); 291 $u_obj = new WP_User( $u ); 292 293 // Fake an old-style registration but without an activation key 294 global $wpdb; 295 $wpdb->update( 296 $wpdb->users, 297 array( 'user_status' => '2', ), 298 array( 'ID' => $u, ), 299 array( '%d', ), 300 array( '%d', ) 301 ); 302 clean_user_cache( $u ); 303 304 bp_members_migrate_signups(); 305 306 // Use email address as a sanity check 307 $found = BP_Signup::get(); 308 $found_email = isset( $found['signups'][0]->user_email ) ? $found['signups'][0]->user_email : ''; 309 $this->assertSame( $u_obj->user_email, $found_email ); 310 } 311 312 /** 313 * @group bp_last_activity_migrate 314 * @expectedIncorrectUsage update_user_meta( $user_id, 'last_activity' ) 315 * @expectedIncorrectUsage get_user_meta( $user_id, 'last_activity' ) 316 */ 317 public function test_bp_last_activity_migrate() { 318 // We explicitly do not want last_activity created, so use the 319 // WP factory methods 320 $u1 = self::factory()->user->create(); 321 $u2 = self::factory()->user->create(); 322 $u3 = self::factory()->user->create(); 323 324 $time = time(); 325 $t1 = date( 'Y-m-d H:i:s', $time - 50 ); 326 $t2 = date( 'Y-m-d H:i:s', $time - 500 ); 327 $t3 = date( 'Y-m-d H:i:s', $time - 5000 ); 328 329 update_user_meta( $u1, 'last_activity', $t1 ); 330 update_user_meta( $u2, 'last_activity', $t2 ); 331 update_user_meta( $u3, 'last_activity', $t3 ); 332 333 // Create an existing entry in last_activity to test no dupes 334 global $wpdb; 335 $bp = buddypress(); 336 $wpdb->query( $wpdb->prepare( 337 "INSERT INTO {$bp->members->table_name_last_activity} 338 (`user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `date_recorded` ) VALUES 339 ( %d, %s, %s, %s, %s, %s, %d, %s )", 340 $u2, $bp->members->id, 'last_activity', '', '', '', 0, $t1 341 ) ); 342 343 bp_last_activity_migrate(); 344 345 $expected = array( 346 $u1 => $t1, 347 $u2 => $t2, 348 $u3 => $t3, 349 ); 350 351 $found = array( 352 $u1 => '', 353 $u2 => '', 354 $u3 => '', 355 ); 356 357 foreach ( $found as $uid => $v ) { 358 $found[ $uid ] = bp_get_user_last_activity( $uid ); 359 } 360 361 $this->assertSame( $expected, $found ); 362 } 363 364 /** 365 * @group bp_core_get_userid_from_nicename 366 */ 367 public function test_bp_core_get_userid_from_nicename_failure() { 368 $this->assertSame( NULL, bp_core_get_userid_from_nicename( 'non_existent_user' ) ); 369 } 370 371 /** 372 * @group bp_update_user_last_activity 373 */ 374 public function test_bp_last_activity_multi_network() { 375 376 // Filter the usermeta key 377 add_filter( 'bp_get_user_meta_key', array( $this, 'filter_usermeta_key' ) ); 378 379 // We explicitly do not want last_activity created, so use the 380 // WP factory methods 381 $user = self::factory()->user->create(); 382 $time = date( 'Y-m-d H:i:s', time() - 50 ); 383 384 // Update last user activity 385 bp_update_user_last_activity( $user, $time ); 386 387 // Setup parameters to assert to be the same 388 $expected = $time; 389 $found = bp_get_user_last_activity( $user ); 390 391 $this->assertSame( $expected, $found ); 392 } 393 394 /** 395 * @group bp_update_user_last_activity 396 * @global object $wpdb 397 * @param string $key 398 * @return string 399 */ 400 public function filter_usermeta_key( $key ) { 401 global $wpdb; 402 return $wpdb->prefix . $key; 403 } 404 405 /** 406 * @group bp_core_process_spammer_status 407 */ 408 public function test_bp_core_process_spammer_status() { 409 if ( is_multisite() ) { 410 $this->markTestSkipped(); 411 } 412 413 $bp = buddypress(); 414 $displayed_user = $bp->displayed_user; 415 416 $u1 = self::factory()->user->create(); 417 $bp->displayed_user->id = $u1; 418 419 // Spam the user 420 bp_core_process_spammer_status( $u1, 'spam' ); 421 422 $this->assertTrue( bp_is_user_spammer( $u1 ) ); 423 424 // Unspam the user 425 bp_core_process_spammer_status( $u1, 'ham' ); 426 427 $this->assertFalse( bp_is_user_spammer( $u1 ) ); 428 429 // Reset displayed user 430 $bp->displayed_user = $displayed_user; 431 } 432 433 /** 434 * @group bp_core_process_spammer_status 435 */ 436 public function test_bp_core_process_spammer_status_ms_bulk_spam() { 437 if ( ! is_multisite() ) { 438 $this->markTestSkipped(); 439 } 440 441 $bp = buddypress(); 442 $displayed_user = $bp->displayed_user; 443 444 $u1 = self::factory()->user->create(); 445 $bp->displayed_user->id = $u1; 446 447 // Bulk spam in network admin uses update_user_status 448 bp_core_update_member_status( $u1, '1' ); 449 450 $this->assertTrue( bp_is_user_spammer( $u1 ) ); 451 452 // Unspam the user 453 bp_core_process_spammer_status( $u1, 'ham' ); 454 455 $this->assertFalse( bp_is_user_spammer( $u1 ) ); 456 457 // Reset displayed user 458 $bp->displayed_user = $displayed_user; 459 } 460 461 /** 462 * @group bp_core_process_spammer_status 463 */ 464 public function test_bp_core_process_spammer_status_ms_bulk_ham() { 465 if ( ! is_multisite() ) { 466 $this->markTestSkipped(); 467 } 468 469 $bp = buddypress(); 470 $displayed_user = $bp->displayed_user; 471 472 $u1 = self::factory()->user->create(); 473 $bp->displayed_user->id = $u1; 474 475 // Spam the user 476 bp_core_process_spammer_status( $u1, 'spam' ); 477 478 $this->assertTrue( bp_is_user_spammer( $u1 ) ); 479 480 // Bulk unspam in network admin uses update_user_status 481 bp_core_update_member_status( $u1, '0' ); 482 483 $this->assertFalse( bp_is_user_spammer( $u1 ) ); 484 485 // Reset displayed user 486 $bp->displayed_user = $displayed_user; 487 } 488 489 /** 490 * @group bp_core_process_spammer_status 491 */ 492 public function test_bp_core_process_spammer_status_make_spam_user_filter() { 493 add_filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) ); 494 495 $u1 = self::factory()->user->create(); 496 $n = bp_core_process_spammer_status( $u1, 'spam' ); 497 498 remove_filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) ); 499 500 $this->assertSame( 'make_spam_user', $this->filter_fired ); 501 502 } 503 504 public function test_bp_core_process_spammer_status_make_ham_user_filter() { 505 $u1 = self::factory()->user->create(); 506 $s = bp_core_process_spammer_status( $u1, 'spam' ); 507 508 add_filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) ); 509 510 $h = bp_core_process_spammer_status( $u1, 'ham' ); 511 512 remove_filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) ); 513 514 $this->assertSame( 'make_ham_user', $this->filter_fired ); 515 516 } 517 518 public function test_bp_core_process_spammer_status_bp_make_spam_user_filter() { 519 add_filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) ); 520 521 $u1 = self::factory()->user->create(); 522 $n = bp_core_process_spammer_status( $u1, 'spam' ); 523 524 remove_filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) ); 525 526 $this->assertSame( 'bp_make_spam_user', $this->filter_fired ); 527 528 } 529 530 public function test_bp_core_process_spammer_status_bp_make_ham_user_filter() { 531 add_filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) ); 532 533 $u1 = self::factory()->user->create(); 534 $n = bp_core_process_spammer_status( $u1, 'ham' ); 535 536 remove_filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) ); 537 538 $this->assertSame( 'bp_make_ham_user', $this->filter_fired ); 539 540 } 541 542 /** 543 * @group bp_core_process_spammer_status 544 * @ticket BP8316 545 */ 546 public function test_bp_core_process_spammer_status_ms_should_only_spam_sites_with_one_admin() { 547 if ( ! is_multisite() ) { 548 $this->markTestSkipped(); 549 } 550 551 $u1 = self::factory()->user->create(); 552 $u2 = self::factory()->user->create(); 553 554 $b1 = self::factory()->blog->create( array( 'user_id' => $u1 ) ); 555 556 // Add user 2 to site as administrator. 557 add_user_to_blog( $b1, $u2, 'administrator' ); 558 559 // Mark user 2 as a spammer. 560 bp_core_process_spammer_status( $u2, 'spam' ); 561 562 // Ensure site isn't marked as spam because there is more than one admin. 563 $site = get_site( $b1 ); 564 $this->assertEmpty( $site->spam ); 565 } 566 567 public function notification_filter_callback( $value ) { 568 $this->filter_fired = current_filter(); 569 return $value; 570 } 571 572 /** 573 * @ticket BP6208 574 * 575 * Note - it's not possible to test this when registration is not configured properly, 576 * because `bp_has_custom_signup_page()` stores its value in a static variable that cannot 577 * be toggled. 578 */ 579 public function test_wp_registration_url_should_return_bp_register_page_when_register_page_is_configured_properly() { 580 $this->assertSame( bp_get_signup_page(), wp_registration_url() ); 581 } 582 583 /** 584 * @group bp_members_validate_user_password 585 */ 586 public function test_bp_members_validate_user_password() { 587 $validate = bp_members_validate_user_password( 'foobar', 'foobar' ); 588 589 $this->assertEmpty( $validate->get_error_message() ); 590 } 591 592 /** 593 * @group bp_members_validate_user_password 594 */ 595 public function test_bp_members_validate_user_password_missing() { 596 $validate = bp_members_validate_user_password( '', '' ); 597 598 $this->assertEquals( 'missing_user_password', $validate->get_error_code() ); 599 600 $validate = bp_members_validate_user_password( 'foobar', '' ); 601 602 $this->assertEquals( 'missing_user_password', $validate->get_error_code() ); 603 604 $validate = bp_members_validate_user_password( '', 'foobar' ); 605 606 $this->assertEquals( 'missing_user_password', $validate->get_error_code() ); 607 } 608 609 /** 610 * @group bp_members_validate_user_password 611 */ 612 public function test_bp_members_validate_user_password_mismatching() { 613 $validate = bp_members_validate_user_password( 'foobar', 'barfoo' ); 614 615 $this->assertEquals( 'mismatching_user_password', $validate->get_error_code() ); 616 } 617 618 /** 619 * @group bp_members_validate_user_password 620 */ 621 public function test_bp_members_validate_user_password_too_short() { 622 add_filter( 'bp_members_validate_user_password', array( $this, 'filter_bp_members_validate_user_password' ), 10, 2 ); 623 624 $validate = bp_members_validate_user_password( 'one', 'one' ); 625 626 remove_filter( 'bp_members_validate_user_password', array( $this, 'filter_bp_members_validate_user_password' ), 10, 2 ); 627 628 $this->assertEquals( 'too_short_user_password', $validate->get_error_code() ); 629 } 630 631 function filter_bp_members_validate_user_password( $errors, $pass ) { 632 if ( 4 > strlen( $pass ) ) { 633 $errors->add( 'too_short_user_password', __( 'Your password is too short.', 'buddypress' ) ); 634 } 635 636 return $errors; 637 } 638 639 /** 640 * @group bp_core_activate_signup 641 */ 642 public function test_bp_core_activate_signup_password() { 643 global $wpdb; 644 645 646 $signups = array( 'no-blog' => 647 array( 'signup_id' => self::factory()->signup->create( array( 648 'user_login' => 'noblog', 649 'user_email' => 'noblog@example.com', 650 'activation_key' => 'no-blog', 651 'meta' => array( 652 'field_1' => 'Foo Bar', 653 'password' => 'foobar', 654 ), 655 ) ), 656 'password' => 'foobar', 657 ), 658 ); 659 660 if ( is_multisite() ) { 661 $signups['ms-blog'] = array( 'signup_id' => self::factory()->signup->create( array( 662 'user_login' => 'msblog', 663 'user_email' => 'msblog@example.com', 664 'domain' => get_current_site()->domain, 665 'path' => get_current_site()->path . 'ms-blog', 666 'title' => 'Ding Dang', 667 'activation_key' => 'ms-blog', 668 'meta' => array( 669 'field_1' => 'Ding Dang', 670 'password' => 'dingdang', 671 ), 672 ) ), 673 'password' => 'dingdang', 674 ); 675 } 676 677 // Neutralize db errors 678 $suppress = $wpdb->suppress_errors(); 679 680 foreach ( $signups as $key => $data ) { 681 $u = bp_core_activate_signup( $key ); 682 683 $this->assertEquals( get_userdata( $u )->user_pass, $data['password'] ); 684 } 685 686 $wpdb->suppress_errors( $suppress ); 687 } 688 689 /** 690 * @ticket BP7461 691 * 692 * Test function before and after adding custom illegal names from WordPress. 693 */ 694 public function test_bp_core_get_illegal_names() { 695 696 // Making sure BP custom illegals are in the array. 697 $this->assertTrue( in_array( 'profile', bp_core_get_illegal_names(), true ) ); 698 $this->assertTrue( in_array( 'forums', bp_core_get_illegal_names(), true ) ); 699 700 add_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); 701 702 // Testing fake custom illegal names. 703 $this->assertTrue( in_array( 'testuser', bp_core_get_illegal_names(), true ) ); 704 $this->assertTrue( in_array( 'admins', bp_core_get_illegal_names(), true ) ); 705 $this->assertFalse( in_array( 'buddypresss', bp_core_get_illegal_names(), true ) ); 706 707 // Making sure BP custom illegals are in the array after including the custom ones. 708 $this->assertTrue( in_array( 'profile', bp_core_get_illegal_names(), true ) ); 709 $this->assertTrue( in_array( 'forums', bp_core_get_illegal_names(), true ) ); 710 711 remove_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); 712 } 713 714 public function _illegal_user_logins() { 715 return array( 716 'testuser', 717 'admins', 718 'buddypress', 719 ); 720 } 721 722 /** 723 * @group bp_core_activate_signup 724 */ 725 public function test_bp_core_activate_signup_should_add_user_role() { 726 $key = 'test'; 727 728 // Create the signup. 729 $this->factory->signup->create( array( 730 'user_login' => 'test', 731 'user_email' => 'test@example.com', 732 'activation_key' => $key, 733 'meta' => array( 734 'field_1' => 'Foo Bar', 735 'password' => 'foobar', 736 ), 737 ) ); 738 739 // Activate user. 740 $user_id = bp_core_activate_signup( $key ); 741 742 // Assert that user has a role. 743 $user = get_userdata( $user_id ); 744 $this->assertNotEmpty( $user->roles ); 745 } 746 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |