- Timestamp:
- 09/09/2021 02:01:40 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/functions/get-group.php
r13097 r13103 23 23 } 24 24 25 /** 26 * @group bp_get_group 27 */ 25 28 public function test_bp_get_group_with_no_group() { 26 29 $this->assertFalse( bp_get_group() ); … … 28 31 } 29 32 33 /** 34 * @group bp_get_group 35 */ 30 36 public function test_bp_get_group_with_id() { 31 37 $g = $this->factory->group->create(); … … 36 42 } 37 43 44 /** 45 * @group bp_get_group 46 */ 38 47 public function test_bp_get_group_with_slug() { 39 48 $slug = 'test-group'; … … 50 59 } 51 60 61 /** 62 * @group bp_get_group 63 */ 52 64 public function test_bp_get_group_with_object() { 53 65 $g = $this->factory->group->create_and_get(); … … 56 68 } 57 69 70 /** 71 * @group bp_get_group 72 */ 58 73 public function test_bp_get_group_from_groups_template() { 59 74 $g = $this->factory->group->create( array( 'status' => 'private' ) ); 60 75 61 // Fake the current group. 62 $GLOBALS['groups_template'] = new stdClass; 63 $GLOBALS['groups_template']->group = groups_get_group( $g ); 76 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { 77 while ( bp_groups() ) { 78 bp_the_group(); 79 $group = bp_get_group(); 80 } 81 } 64 82 65 $this->assertSame( $g, bp_get_group()->id ); 83 $this->assertSame( $g, $group->id ); 84 } 85 86 /** 87 * @group bp_get_group 88 */ 89 public function test_bp_get_group_from_current_group() { 90 $bp = buddypress(); 91 $g = $this->factory->group->create_and_get( array( 'name' => 'foo' ) ); 92 93 // Set the current group. 94 $bp->groups->current_group = $g; 95 96 // Change the name to check the current group was used. 97 $bp->groups->current_group->name = 'bar'; 98 99 // Override the name 100 do_action( 'bp_groups_set_current_group' ); 101 102 $this->assertSame( 'bar', bp_get_group( $g->id )->name ); 66 103 } 67 104 }
Note: See TracChangeset
for help on using the changeset viewer.