[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Tests for the `groups_create_group()` function. 5 * 6 * @group groups 7 */ 8 class BP_Tests_Groups_Functions_GroupsCreateGroup extends BP_UnitTestCase { 9 static $user_id; 10 11 public static function wpSetUpBeforeClass( $factory ) { 12 self::$user_id = $factory->user->create(); 13 } 14 15 public static function wpTearDownAfterClass() { 16 self::delete_user( self::$user_id ); 17 } 18 19 /** 20 * @ticket BP7619 21 */ 22 public function test_should_respect_creator_id() { 23 $old_user_id = bp_loggedin_user_id(); 24 $this->set_current_user( self::$user_id ); 25 26 $group_id = groups_create_group( array( 27 'name' => 'Foo', 28 'creator_id' => self::$user_id + 1, 29 ) ); 30 31 $group = groups_get_group( $group_id ); 32 33 $this->set_current_user( $old_user_id ); 34 35 $this->assertSame( self::$user_id + 1, $group->creator_id ); 36 } 37 38 /** 39 * @ticket BP7619 40 */ 41 public function test_creator_id_should_be_fall_back_to_loggedin_user_for_new_group() { 42 $old_user_id = bp_loggedin_user_id(); 43 $this->set_current_user( self::$user_id ); 44 45 $group_id = groups_create_group( array( 46 'name' => 'Foo', 47 ) ); 48 49 $group = groups_get_group( $group_id ); 50 51 $this->set_current_user( $old_user_id ); 52 53 $this->assertSame( self::$user_id, $group->creator_id ); 54 } 55 56 /** 57 * @ticket BP7619 58 */ 59 public function test_creator_id_should_be_fall_back_to_existing_creator_id_for_existing_group() { 60 $group_id = self::factory()->group->create( array( 61 'creator_id' => self::$user_id + 1, 62 ) ); 63 64 $old_user_id = bp_loggedin_user_id(); 65 $this->set_current_user( self::$user_id ); 66 67 $group_id = groups_create_group( array( 68 'group_id' => $group_id, 69 ) ); 70 71 $group = groups_get_group( $group_id ); 72 73 $this->set_current_user( $old_user_id ); 74 75 $this->assertSame( self::$user_id + 1, $group->creator_id ); 76 } 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |