Changeset 13280 for trunk/tests/phpunit/testcases/groups/functions.php
- Timestamp:
- 05/18/2022 05:32:26 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/functions.php
r13103 r13280 8 8 static public $group_ids; 9 9 static public $user_ids; 10 protected $did_group_member_count = 0; 10 11 11 12 static public function wpSetUpBeforeClass( $factory ) { … … 343 344 $this->assertEquals( 2, groups_get_total_member_count( $g1 ) ); 344 345 $this->assertEquals( 2, BP_Groups_Group::get_total_member_count( $g1 ) ); 346 } 347 348 /** 349 * @group total_member_count 350 * @ticket BP8688 351 */ 352 public function test_total_member_count_groups_inactive_user() { 353 $u1 = self::factory()->user->create(); 354 $u2 = wp_insert_user( array( 355 'user_pass' => 'foobar', 356 'user_login' => 'foobar', 357 'user_email' => 'foobar@buddypress.org', 358 ) ); 359 360 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 361 362 groups_join_group( $g1, $u2 ); 363 364 $this->assertEquals( 1, groups_get_total_member_count( $g1 ) ); 365 } 366 367 /** 368 * @group total_member_count 369 * @ticket BP8688 370 */ 371 public function test_total_member_count_groups_spammed_user() { 372 $u1 = self::factory()->user->create(); 373 $u2 = self::factory()->user->create(); 374 375 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 376 377 groups_join_group( $g1, $u2 ); 378 bp_core_process_spammer_status( $u2, 'spam' ); 379 380 $this->assertEquals( 1, groups_get_total_member_count( $g1 ) ); 381 } 382 383 /** 384 * @group total_member_count 385 * @ticket BP8688 386 */ 387 public function test_total_member_count_groups_deferred() { 388 $u1 = self::factory()->user->create(); 389 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 390 $members = array(); 391 $this->did_group_member_count = 0; 392 393 add_filter( 'bp_groups_total_member_count', array( $this, 'filter_bp_groups_total_member_count' ) ); 394 395 bp_groups_defer_group_members_count( true ); 396 for ( $i = 1; $i < 6; $i++ ) { 397 $members[ $i ] = self::factory()->user->create(); 398 groups_join_group( $g1, $members[ $i ] ); 399 } 400 bp_groups_defer_group_members_count( false, $g1 ); 401 402 remove_filter( 'bp_groups_total_member_count', array( $this, 'filter_bp_groups_total_member_count' ) ); 403 404 $this->assertTrue( 1 === $this->did_group_member_count ); 405 $this->assertEquals( count( $members ) + 1, groups_get_total_member_count( $g1 ) ); 406 } 407 408 public function filter_bp_groups_total_member_count( $count ) { 409 $this->did_group_member_count += 1; 410 return $count; 345 411 } 346 412
Note: See TracChangeset
for help on using the changeset viewer.