Changeset 11737 for trunk/tests/phpunit/testcases/groups/functions.php
- Timestamp:
- 11/03/2017 07:44:10 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/functions.php
r11558 r11737 7 7 class BP_Tests_Groups_Functions extends BP_UnitTestCase { 8 8 public function test_creating_new_group_as_authenticated_user() { 9 $u = $this->factory->user->create();9 $u = self::factory()->user->create(); 10 10 wp_set_current_user( $u ); 11 11 12 $this->factory->group->create();12 self::factory()->group->create(); 13 13 } 14 14 … … 18 18 */ 19 19 public function test_total_group_count_groups_join_group() { 20 $u1 = $this->factory->user->create();21 $u2 = $this->factory->user->create();22 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );20 $u1 = self::factory()->user->create(); 21 $u2 = self::factory()->user->create(); 22 $g = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 23 23 24 24 groups_join_group( $g, $u2 ); … … 31 31 */ 32 32 public function test_total_group_count_groups_leave_group() { 33 $u1 = $this->factory->user->create();34 $u2 = $this->factory->user->create();35 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );36 $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );33 $u1 = self::factory()->user->create(); 34 $u2 = self::factory()->user->create(); 35 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 36 $g2 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 37 37 groups_join_group( $g1, $u2 ); 38 38 groups_join_group( $g2, $u2 ); … … 49 49 */ 50 50 public function test_total_group_count_groups_ban_member() { 51 $u1 = $this->factory->user->create();52 $u2 = $this->factory->user->create();53 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );54 $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );51 $u1 = self::factory()->user->create(); 52 $u2 = self::factory()->user->create(); 53 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 54 $g2 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 55 55 groups_join_group( $g1, $u2 ); 56 56 groups_join_group( $g2, $u2 ); … … 70 70 */ 71 71 public function test_total_group_count_groups_unban_member() { 72 $u1 = $this->factory->user->create();73 $u2 = $this->factory->user->create();74 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );75 $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );72 $u1 = self::factory()->user->create(); 73 $u2 = self::factory()->user->create(); 74 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 75 $g2 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 76 76 groups_join_group( $g1, $u2 ); 77 77 groups_join_group( $g2, $u2 ); … … 93 93 */ 94 94 public function test_total_group_count_groups_accept_invite() { 95 $u1 = $this->factory->user->create();96 $u2 = $this->factory->user->create();97 $g = $this->factory->group->create();95 $u1 = self::factory()->user->create(); 96 $u2 = self::factory()->user->create(); 97 $g = self::factory()->group->create(); 98 98 groups_invite_user( array( 99 99 'user_id' => $u1, … … 112 112 */ 113 113 public function test_total_group_count_groups_accept_membership_request() { 114 $u1 = $this->factory->user->create();115 $u2 = $this->factory->user->create();114 $u1 = self::factory()->user->create(); 115 $u2 = self::factory()->user->create(); 116 116 117 117 $current_user = bp_loggedin_user_id(); 118 118 $this->set_current_user( $u2 ); 119 119 120 $g = $this->factory->group->create();120 $g = self::factory()->group->create(); 121 121 groups_send_membership_request( $u1, $g ); 122 122 … … 133 133 */ 134 134 public function test_total_group_count_groups_remove_member() { 135 $u1 = $this->factory->user->create();136 $u2 = $this->factory->user->create();137 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );138 $g2 = $this->factory->group->create( array( 'creator_id' => $u1 ) );135 $u1 = self::factory()->user->create(); 136 $u2 = self::factory()->user->create(); 137 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 138 $g2 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 139 139 groups_join_group( $g1, $u2 ); 140 140 groups_join_group( $g2, $u2 ); … … 154 154 */ 155 155 public function test_total_member_count_groups_join_group() { 156 $u1 = $this->factory->user->create();157 $u2 = $this->factory->user->create();158 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );156 $u1 = self::factory()->user->create(); 157 $u2 = self::factory()->user->create(); 158 $g = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 159 159 160 160 groups_join_group( $g, $u2 ); … … 167 167 */ 168 168 public function test_total_member_count_groups_leave_group() { 169 $u1 = $this->factory->user->create();170 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );169 $u1 = self::factory()->user->create(); 170 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 171 171 groups_join_group( $g1, $u1 ); 172 172 … … 180 180 */ 181 181 public function test_total_member_count_groups_ban_member() { 182 $u1 = $this->factory->user->create();183 $u2 = $this->factory->user->create();184 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );182 $u1 = self::factory()->user->create(); 183 $u2 = self::factory()->user->create(); 184 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 185 185 groups_join_group( $g1, $u2 ); 186 186 … … 199 199 */ 200 200 public function test_total_member_count_groups_unban_member() { 201 $u1 = $this->factory->user->create();202 $u2 = $this->factory->user->create();203 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );201 $u1 = self::factory()->user->create(); 202 $u2 = self::factory()->user->create(); 203 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 204 204 groups_join_group( $g1, $u2 ); 205 205 … … 220 220 */ 221 221 public function test_total_member_count_groups_accept_invite() { 222 $u1 = $this->factory->user->create();223 $u2 = $this->factory->user->create();224 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );222 $u1 = self::factory()->user->create(); 223 $u2 = self::factory()->user->create(); 224 $g = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 225 225 groups_invite_user( array( 226 226 'user_id' => $u1, … … 239 239 */ 240 240 public function test_total_member_count_groups_accept_membership_request() { 241 $u1 = $this->factory->user->create();242 $u2 = $this->factory->user->create();243 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );241 $u1 = self::factory()->user->create(); 242 $u2 = self::factory()->user->create(); 243 $g = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 244 244 245 245 groups_send_membership_request( $u2, $g ); … … 254 254 */ 255 255 public function test_total_member_count_groups_remove_member() { 256 $u1 = $this->factory->user->create();257 $u2 = $this->factory->user->create();258 $g1 = $this->factory->group->create( array( 'creator_id' => $u1 ) );256 $u1 = self::factory()->user->create(); 257 $u2 = self::factory()->user->create(); 258 $g1 = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 259 259 groups_join_group( $g1, $u2 ); 260 260 … … 273 273 */ 274 274 public function test_total_member_count_groups_create_group() { 275 $u1 = $this->factory->user->create();275 $u1 = self::factory()->user->create(); 276 276 $g = groups_create_group( array( 277 277 'creator_id' => $u1, … … 291 291 */ 292 292 public function test_groups_create_group_dont_delete_description_for_existing_group_when_no_description_is_passed() { 293 $g = $this->factory->group->create();293 $g = self::factory()->group->create(); 294 294 295 295 $group_before = groups_get_group( $g ); … … 308 308 */ 309 309 public function test_groups_update_groupmeta_with_line_breaks() { 310 $g = $this->factory->group->create();310 $g = self::factory()->group->create(); 311 311 $meta_value = 'Foo! 312 312 … … 328 328 */ 329 329 public function test_groups_update_groupmeta_stripslashes() { 330 $g = $this->factory->group->create();330 $g = self::factory()->group->create(); 331 331 $value = "This string is totally slashin\'!"; 332 332 groups_update_groupmeta( $g, 'foo', $value ); … … 339 339 */ 340 340 public function test_groups_update_groupmeta_new() { 341 $g = $this->factory->group->create();341 $g = self::factory()->group->create(); 342 342 $this->assertSame( '', groups_get_groupmeta( $g, 'foo' ), '"foo" meta should be empty for this group.' ); 343 343 $this->assertNotEmpty( groups_update_groupmeta( $g, 'foo', 'bar' ) ); … … 349 349 */ 350 350 public function test_groups_update_groupmeta_existing() { 351 $g = $this->factory->group->create();351 $g = self::factory()->group->create(); 352 352 groups_update_groupmeta( $g, 'foo', 'bar' ); 353 353 $this->assertSame( 'bar', groups_get_groupmeta( $g, 'foo' ), '"foo" meta should be set already for this group.' ); … … 360 360 */ 361 361 public function test_groups_update_groupmeta_existing_same_value() { 362 $g = $this->factory->group->create();362 $g = self::factory()->group->create(); 363 363 groups_update_groupmeta( $g, 'foo', 'bar' ); 364 364 $this->assertSame( 'bar', groups_get_groupmeta( $g, 'foo' ), '"foo" meta should be set already for this group.' ); … … 372 372 */ 373 373 public function test_groups_update_groupmeta_prev_value() { 374 $g = $this->factory->group->create();374 $g = self::factory()->group->create(); 375 375 groups_add_groupmeta( $g, 'foo', 'bar' ); 376 376 … … 393 393 */ 394 394 public function test_groups_get_groupmeta_with_illegal_key_characters() { 395 $g = $this->factory->group->create();395 $g = self::factory()->group->create(); 396 396 groups_update_groupmeta( $g, 'foo', 'bar' ); 397 397 … … 404 404 */ 405 405 public function test_groups_get_groupmeta_all_metas() { 406 $g = $this->factory->group->create();406 $g = self::factory()->group->create(); 407 407 groups_update_groupmeta( $g, 'foo', 'bar' ); 408 408 groups_update_groupmeta( $g, 'Boone', 'is cool' ); … … 430 430 */ 431 431 public function test_groups_get_groupmeta_all_metas_empty() { 432 $g = $this->factory->group->create();432 $g = self::factory()->group->create(); 433 433 434 434 // Get rid of any auto-created values … … 447 447 */ 448 448 public function test_groups_get_groupmeta_empty() { 449 $g = $this->factory->group->create();449 $g = self::factory()->group->create(); 450 450 $this->assertSame( '', groups_get_groupmeta( $g, 'foo' ) ); 451 451 } … … 456 456 */ 457 457 public function test_bp_activity_get_meta_single_true() { 458 $g = $this->factory->group->create();458 $g = self::factory()->group->create(); 459 459 groups_add_groupmeta( $g, 'foo', 'bar' ); 460 460 groups_add_groupmeta( $g, 'foo', 'baz' ); … … 468 468 */ 469 469 public function test_bp_activity_get_meta_single_false() { 470 $g = $this->factory->group->create();470 $g = self::factory()->group->create(); 471 471 groups_add_groupmeta( $g, 'foo', 'bar' ); 472 472 groups_add_groupmeta( $g, 'foo', 'baz' ); … … 480 480 */ 481 481 public function test_groups_get_groupmeta_cache_all_on_get() { 482 $g = $this->factory->group->create();482 $g = self::factory()->group->create(); 483 483 groups_add_groupmeta( $g, 'foo', 'bar' ); 484 484 groups_add_groupmeta( $g, 'foo1', 'baz' ); … … 505 505 */ 506 506 public function test_groups_delete_groupmeta_with_illegal_key_characters() { 507 $g = $this->factory->group->create();507 $g = self::factory()->group->create(); 508 508 $this->assertNotEmpty( groups_update_groupmeta( $g, 'foo', 'bar' ), 'Value of "foo" should be set at this point.' ); 509 509 … … 520 520 global $wpdb; 521 521 522 $g = $this->factory->group->create();522 $g = self::factory()->group->create(); 523 523 $m = groups_get_groupmeta( $g ); 524 524 foreach ( $m as $mk => $mv ) { … … 537 537 // With no meta key, don't delete for all items - just delete 538 538 // all for a single item 539 $g1 = $this->factory->group->create();540 $g2 = $this->factory->group->create();539 $g1 = self::factory()->group->create(); 540 $g2 = self::factory()->group->create(); 541 541 groups_add_groupmeta( $g1, 'foo', 'bar' ); 542 542 groups_add_groupmeta( $g1, 'foo1', 'bar1' ); … … 557 557 // With no meta key, don't delete for all items - just delete 558 558 // all for a single item 559 $g1 = $this->factory->group->create();560 $g2 = $this->factory->group->create();559 $g1 = self::factory()->group->create(); 560 $g2 = self::factory()->group->create(); 561 561 groups_add_groupmeta( $g1, 'foo', 'bar' ); 562 562 groups_add_groupmeta( $g1, 'foo1', 'bar1' ); … … 592 592 */ 593 593 public function test_groups_add_groupmeta_existing_unique() { 594 $g = $this->factory->group->create();594 $g = self::factory()->group->create(); 595 595 groups_add_groupmeta( $g, 'foo', 'bar' ); 596 596 $this->assertFalse( groups_add_groupmeta( $g, 'foo', 'baz', true ) ); … … 602 602 */ 603 603 public function test_groups_add_groupmeta_existing_not_unique() { 604 $g = $this->factory->group->create();604 $g = self::factory()->group->create(); 605 605 groups_add_groupmeta( $g, 'foo', 'bar' ); 606 606 $this->assertNotEmpty( groups_add_groupmeta( $g, 'foo', 'baz' ) ); … … 611 611 */ 612 612 public function test_get_invite_count_for_user() { 613 $u1 = $this->factory->user->create();614 $u2 = $this->factory->user->create();615 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );613 $u1 = self::factory()->user->create(); 614 $u2 = self::factory()->user->create(); 615 $g = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 616 616 617 617 // create invitation … … 640 640 */ 641 641 public function test_update_orphaned_groups_on_group_delete_top_level() { 642 $g1 = $this->factory->group->create();643 $g2 = $this->factory->group->create( array(642 $g1 = self::factory()->group->create(); 643 $g2 = self::factory()->group->create( array( 644 644 'parent_id' => $g1, 645 645 ) ); … … 655 655 */ 656 656 public function test_update_orphaned_groups_on_group_delete_two_levels() { 657 $g1 = $this->factory->group->create();658 $g2 = $this->factory->group->create( array(657 $g1 = self::factory()->group->create(); 658 $g2 = self::factory()->group->create( array( 659 659 'parent_id' => $g1, 660 660 ) ); 661 $g3 = $this->factory->group->create( array(661 $g3 = self::factory()->group->create( array( 662 662 'parent_id' => $g2, 663 663 ) ); … … 674 674 */ 675 675 public function test_groups_get_group_accept_integer() { 676 $g1 = $this->factory->group->create();676 $g1 = self::factory()->group->create(); 677 677 $group = groups_get_group( $g1 ); 678 678 … … 685 685 */ 686 686 public function test_groups_get_group_accept_numeric() { 687 $g1 = $this->factory->group->create();687 $g1 = self::factory()->group->create(); 688 688 $group = groups_get_group( (string) $g1 ); 689 689 … … 696 696 */ 697 697 public function test_groups_get_group_accept_array() { 698 $g1 = $this->factory->group->create();698 $g1 = self::factory()->group->create(); 699 699 $group = groups_get_group( array( 'group_id' => $g1 ) ); 700 700 … … 707 707 */ 708 708 public function test_groups_get_group_accept_query_string() { 709 $g1 = $this->factory->group->create();709 $g1 = self::factory()->group->create(); 710 710 $group = groups_get_group( 'group_id=' . $g1 ); 711 711 … … 718 718 */ 719 719 public function test_groups_edit_base_group_details_test_backcompat_arguments() { 720 $g1 = $this->factory->group->create();720 $g1 = self::factory()->group->create(); 721 721 $name = 'Great Scott'; 722 722 $description = 'A must-see in time for the holidays!'; … … 742 742 */ 743 743 public function test_groups_edit_base_group_details_test_new_arguments() { 744 $g1 = $this->factory->group->create();744 $g1 = self::factory()->group->create(); 745 745 $name = 'Great Scott'; 746 746 $slug = 'what-about-it'; … … 776 776 public function test_groups_edit_base_group_details_avoid_slug_collisions() { 777 777 $slug = 'circe'; 778 $g1 = $this->factory->group->create( array( 'slug' => $slug ) );779 $g2 = $this->factory->group->create( array( 'slug' => 'loom' ) );778 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 779 $g2 = self::factory()->group->create( array( 'slug' => 'loom' ) ); 780 780 781 781 // Attempt to use a duplicate slug. … … 795 795 public function test_groups_edit_base_group_details_slug_no_change() { 796 796 $slug = 'circe'; 797 $g1 = $this->factory->group->create( array( 'slug' => $slug ) );797 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 798 798 799 799 // Make sure the slug doesn't get incremented when there's no change. … … 813 813 public function test_groups_edit_base_group_details_slug_null_value() { 814 814 $slug = 'circe'; 815 $g1 = $this->factory->group->create( array( 'slug' => $slug ) );815 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 816 816 817 817 // Make sure the slug doesn't get changed when null is passed. … … 831 831 public function test_groups_get_id_by_previous_slug() { 832 832 $slug = 'circe'; 833 $g1 = $this->factory->group->create( array( 'slug' => $slug ) );834 $g2 = $this->factory->group->create( array( 'slug' => 'loom' ) );833 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 834 $g2 = self::factory()->group->create( array( 'slug' => 'loom' ) ); 835 835 836 836 groups_edit_base_group_details( array(
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)