Skip to:
Content

BuddyPress.org

Ticket #6155: 6155.unittests.patch

File 6155.unittests.patch, 1.0 KB (added by imath, 5 years ago)

Unit tests for bp_core_get_active_member_count()

  • tests/phpunit/testcases/members/functions.php

    diff --git tests/phpunit/testcases/members/functions.php tests/phpunit/testcases/members/functions.php
    index 185b332..c37ceaa 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        }
    589613}