| 651 | |
| 652 | /** |
| 653 | * @group bp_core_process_spammer_status |
| 654 | */ |
| 655 | public function test_bp_core_process_spammer_status() { |
| 656 | if ( is_multisite() ) { |
| 657 | return; |
| 658 | } |
| 659 | |
| 660 | $bp = buddypress(); |
| 661 | $displayed_user = $bp->displayed_user; |
| 662 | |
| 663 | $u1 = $this->factory->user->create(); |
| 664 | $bp->displayed_user->id = $u1; |
| 665 | |
| 666 | // Spam the user |
| 667 | bp_core_process_spammer_status( $u1, 'spam' ); |
| 668 | |
| 669 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
| 670 | |
| 671 | // Unspam the user |
| 672 | bp_core_process_spammer_status( $u1, 'ham' ); |
| 673 | |
| 674 | clean_user_cache( $u1 ); |
| 675 | |
| 676 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
| 677 | |
| 678 | // Reset displayed user |
| 679 | $bp->displayed_user = $displayed_user; |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * @group bp_core_process_spammer_status |
| 684 | */ |
| 685 | public function test_bp_core_process_spammer_status_ms_bulk_spam() { |
| 686 | if ( ! is_multisite() ) { |
| 687 | return; |
| 688 | } |
| 689 | |
| 690 | $bp = buddypress(); |
| 691 | $displayed_user = $bp->displayed_user; |
| 692 | |
| 693 | $u1 = $this->factory->user->create(); |
| 694 | $bp->displayed_user->id = $u1; |
| 695 | |
| 696 | // Bulk spam in network admin uses update_user_status |
| 697 | update_user_status( $u1, 'spam', '1' ); |
| 698 | |
| 699 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
| 700 | |
| 701 | // Unspam the user |
| 702 | bp_core_process_spammer_status( $u1, 'ham' ); |
| 703 | |
| 704 | clean_user_cache( $u1 ); |
| 705 | |
| 706 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
| 707 | |
| 708 | // Reset displayed user |
| 709 | $bp->displayed_user = $displayed_user; |
| 710 | } |
| 711 | |
| 712 | /** |
| 713 | * @group bp_core_process_spammer_status |
| 714 | */ |
| 715 | public function test_bp_core_process_spammer_status_ms_bulk_ham() { |
| 716 | if ( ! is_multisite() ) { |
| 717 | return; |
| 718 | } |
| 719 | |
| 720 | $bp = buddypress(); |
| 721 | $displayed_user = $bp->displayed_user; |
| 722 | |
| 723 | $u1 = $this->factory->user->create(); |
| 724 | $bp->displayed_user->id = $u1; |
| 725 | |
| 726 | // Spam the user |
| 727 | bp_core_process_spammer_status( $u1, 'spam' ); |
| 728 | |
| 729 | $this->assertTrue( bp_is_user_spammer( $u1 ) ); |
| 730 | |
| 731 | // Bulk unspam in network admin uses update_user_status |
| 732 | update_user_status( $u1, 'spam', '0' ); |
| 733 | |
| 734 | clean_user_cache( $u1 ); |
| 735 | |
| 736 | $this->assertFalse( bp_is_user_spammer( $u1 ) ); |
| 737 | |
| 738 | // Reset displayed user |
| 739 | $bp->displayed_user = $displayed_user; |
| 740 | } |