Skip to:
Content

BuddyPress.org

Ticket #6155: 6155.02.unittests.patch

File 6155.02.unittests.patch, 1.8 KB (added by imath, 5 years ago)
  • tests/phpunit/testcases/members/functions.php

    diff --git tests/phpunit/testcases/members/functions.php tests/phpunit/testcases/members/functions.php
    index 185b332..e2c9e62 100644
    class BP_Tests_Members_Functions extends BP_UnitTestCase { 
    586586                $this->filter_fired = current_filter();
    587587                return $value;
    588588        }
     589
     590        /**
     591         * @ticket BP6155
     592         */
     593        public function test_bp_core_get_active_member_count() {
     594                //Get the count before doing any tests
     595                $active_members_count = bp_core_get_active_member_count();
     596
     597                // Reset the transient
     598                delete_transient( 'bp_active_member_count' );
     599
     600                $u1 = $this->factory->user->create();
     601                $u2 = $this->factory->user->create();
     602
     603                $this->assertTrue( $active_members_count + 2 == bp_core_get_active_member_count() );
     604
     605                // Reset the transient
     606                delete_transient( 'bp_active_member_count' );
     607
     608                // Spam user 2
     609                bp_core_process_spammer_status( $u2, 'spam' );
     610
     611                $this->assertTrue( $active_members_count + 1 == bp_core_get_active_member_count() );
     612        }
     613
     614        /**
     615         * @ticket BP6155
     616         */
     617        public function test_bp_core_get_active_member_count_bulk_spam() {
     618                if ( ! is_multisite() ) {
     619                        return;
     620                }
     621
     622                //Get the count before doing any tests
     623                $active_members_count = bp_core_get_active_member_count();
     624
     625                // Reset the transient
     626                delete_transient( 'bp_active_member_count' );
     627
     628                $u1 = $this->factory->user->create();
     629                $u2 = $this->factory->user->create();
     630
     631                $this->assertTrue( $active_members_count + 2 == bp_core_get_active_member_count() );
     632
     633                // Reset the transient
     634                delete_transient( 'bp_active_member_count' );
     635
     636                // Bulk spam the users
     637                update_user_status( $u1, 'spam', '1' );
     638                update_user_status( $u2, 'spam', '1' );
     639
     640                $this->assertTrue( $active_members_count == bp_core_get_active_member_count() );
     641        }
    589642}