| 617 | |
| 618 | /** |
| 619 | * @group bp_core_process_spammer_status |
| 620 | */ |
| 621 | public function test_bp_core_process_spammer_status() { |
| 622 | if ( is_multisite() ) { |
| 623 | return; |
| 624 | } |
| 625 | |
| 626 | $bp = buddypress(); |
| 627 | $displayed_user = $bp->displayed_user; |
| 628 | |
| 629 | $u1 = $this->factory->user->create(); |
| 630 | $bp->displayed_user->id = $u1; |
| 631 | |
| 632 | // Spam the user |
| 633 | bp_core_process_spammer_status( $u1, 'spam' ); |
| 634 | |
| 635 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
| 636 | |
| 637 | // Unspam the user |
| 638 | bp_core_process_spammer_status( $u1, 'ham' ); |
| 639 | |
| 640 | clean_user_cache( $u1 ); |
| 641 | |
| 642 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
| 643 | |
| 644 | // Reset displayed user |
| 645 | $bp->displayed_user = $displayed_user; |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * @group bp_core_process_spammer_status |
| 650 | */ |
| 651 | public function test_bp_core_process_spammer_status_ms_bulk_spam() { |
| 652 | if ( ! is_multisite() ) { |
| 653 | return; |
| 654 | } |
| 655 | |
| 656 | $bp = buddypress(); |
| 657 | $displayed_user = $bp->displayed_user; |
| 658 | |
| 659 | $u1 = $this->factory->user->create(); |
| 660 | $bp->displayed_user->id = $u1; |
| 661 | |
| 662 | // Bulk spam in network admin uses update_user_status |
| 663 | update_user_status( $u1, 'spam', '1' ); |
| 664 | |
| 665 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
| 666 | |
| 667 | // Unspam the user |
| 668 | bp_core_process_spammer_status( $u1, 'ham' ); |
| 669 | |
| 670 | clean_user_cache( $u1 ); |
| 671 | |
| 672 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
| 673 | |
| 674 | // Reset displayed user |
| 675 | $bp->displayed_user = $displayed_user; |
| 676 | } |
| 677 | |
| 678 | /** |
| 679 | * @group bp_core_process_spammer_status |
| 680 | */ |
| 681 | public function test_bp_core_process_spammer_status_ms_bulk_ham() { |
| 682 | if ( ! is_multisite() ) { |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | $bp = buddypress(); |
| 687 | $displayed_user = $bp->displayed_user; |
| 688 | |
| 689 | $u1 = $this->factory->user->create(); |
| 690 | $bp->displayed_user->id = $u1; |
| 691 | |
| 692 | // Spam the user |
| 693 | bp_core_process_spammer_status( $u1, 'spam' ); |
| 694 | |
| 695 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
| 696 | |
| 697 | // Bulk unspam in network admin uses update_user_status |
| 698 | update_user_status( $u1, 'spam', '0' ); |
| 699 | |
| 700 | clean_user_cache( $u1 ); |
| 701 | |
| 702 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
| 703 | |
| 704 | // Reset displayed user |
| 705 | $bp->displayed_user = $displayed_user; |
| 706 | } |