Changeset 13097 for trunk/tests/phpunit/testcases/groups/template.php
- Timestamp:
- 08/26/2021 01:29:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/template.php
r12744 r13097 5 5 */ 6 6 class BP_Tests_Groups_Template extends BP_UnitTestCase { 7 8 public function setUp() { 9 parent::setUp(); 10 11 if ( isset( $GLOBALS['groups_template'] ) ) { 12 $this->groups_template = $GLOBALS['groups_template']; 13 } 14 } 15 16 public function tearDown() { 17 if ( $this->groups_template ) { 18 $GLOBALS['groups_template'] = $this->groups_template; 19 } 20 21 parent::tearDown(); 22 } 23 7 24 /** 8 25 * Integration test to make sure meta_query is getting passed through … … 951 968 952 969 /** 970 * @group bp_group_is_forum_enabled 971 */ 972 public function test_bp_group_is_forum_enabled() { 973 $g1 = $this->factory->group->create( array( 'enable_forum' => 0 ) ); 974 $g2 = $this->factory->group->create( array( 'enable_forum' => 1 ) ); 975 976 $this->assertFalse( bp_group_is_forum_enabled( $g1 ) ); 977 $this->assertTrue( bp_group_is_forum_enabled( $g2 ) ); 978 } 979 980 /** 981 * @group bp_get_group_member_is_banned 982 */ 983 public function test_bp_group_member_is_banned() { 984 $this->assertFalse( bp_get_group_member_is_banned() ); 985 } 986 987 /** 988 * @group bp_get_group_member_id 989 */ 990 public function test_bp_get_group_member_id() { 991 $this->assertFalse( (bool) bp_get_group_member_id() ); 992 } 993 994 /** 995 * @group bp_get_group_form_action 996 */ 997 public function test_bp_bp_get_group_form_action_when_empty() { 998 $this->assertEmpty( bp_get_group_form_action( '' ) ); 999 } 1000 1001 /** 1002 * @group bp_get_group_form_action 1003 */ 1004 public function test_bp_bp_get_group_form_action() { 1005 $g = $this->factory->group->create(); 1006 $p = 2; 1007 $url = trailingslashit( bp_get_group_permalink( $g ) . $p ); 1008 1009 $this->assertSame( bp_get_group_form_action( $p, $g ), $url ); 1010 } 1011 1012 /** 953 1013 * @group bp_get_group_member_count 954 1014 */ 955 1015 public function test_bp_get_group_member_count_0_members() { 956 global $groups_template;957 $g t = $groups_template;958 $groups_template = new stdClass; 959 $groups_template->group = new stdClass;960 $ groups_template->group->total_member_count = 0;961 962 $found = bp_get_group_member_count(); 963 964 $groups_template = $gt;965 966 $this->assert Same( '0 members', $found);1016 $u = $this->factory->user->create(); 1017 $g = $this->factory->group->create( array( 'creator_id' => $u ) ); 1018 1019 // Fake the current group. 1020 $GLOBALS['groups_template'] = new stdClass; 1021 $GLOBALS['groups_template']->group = groups_get_group( $g ); 1022 1023 // Kick group creator. 1024 wp_delete_user( $u ); 1025 1026 $this->assertNotSame( '0 member', bp_get_group_member_count() ); 967 1027 } 968 1028 … … 971 1031 */ 972 1032 public function test_bp_get_group_member_count_1_member() { 973 global $groups_template; 974 $gt = $groups_template; 975 $groups_template = new stdClass; 976 $groups_template->group = new stdClass; 977 $groups_template->group->total_member_count = 1; 978 979 $found = bp_get_group_member_count(); 980 981 $groups_template = $gt; 982 983 $this->assertSame( '1 member', $found ); 1033 $g = $this->factory->group->create(); 1034 1035 // Fake the current group. 1036 $GLOBALS['groups_template'] = new stdClass; 1037 $GLOBALS['groups_template']->group = groups_get_group( $g ); 1038 1039 $this->assertSame( '1 member', bp_get_group_member_count() ); 984 1040 } 985 1041 … … 988 1044 */ 989 1045 public function test_bp_get_group_member_count_2_members() { 990 global $groups_template;991 $ gt = $groups_template;992 $g roups_template = new stdClass;993 $groups_template->group = new stdClass; 994 $ groups_template->group->total_member_count = 2;995 996 $found = bp_get_group_member_count();997 998 $ groups_template = $gt;999 1000 $this->assertSame( '2 members', $found);1046 $u1 = $this->factory->user->create(); 1047 $u2 = $this->factory->user->create(); 1048 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); 1049 1050 $this->add_user_to_group( $u2, $g ); 1051 1052 // Fake the current group. 1053 $GLOBALS['groups_template'] = new stdClass; 1054 $GLOBALS['groups_template']->group = groups_get_group( $g ); 1055 1056 $this->assertSame( '2 members', bp_get_group_member_count() ); 1001 1057 } 1002 1058
Note: See TracChangeset
for help on using the changeset viewer.