- Timestamp:
- 11/14/2014 02:01:30 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/apis/suggestions-nonauth.php
r8958 r9142 7 7 */ 8 8 class BP_Tests_Suggestions_Non_Authenticated extends BP_UnitTestCase { 9 protected $group_ids = array();10 protected $group_slugs = array();11 protected $user_ids = array();9 protected static $group_ids = array(); 10 protected static $group_slugs = array(); 11 protected static $user_ids = array(); 12 12 13 public function setUp() {14 parent::setUp ();13 public static function setUpBeforeClass() { 14 parent::setUpBeforeClass(); 15 15 16 16 $users = array( … … 29 29 ); 30 30 31 $factory = new BP_UnitTest_Factory(); 32 31 33 // Create some dummy users. 32 foreach( $users as $user ) {33 $ this->user_ids[ $user[0] ] = $this->create_user( array(34 foreach( $users as $user_index => $user ) { 35 $new_user = $factory->user->create( array( 34 36 'display_name' => $user[1], 35 37 'user_login' => $user[0], 38 'user_email' => "test-$user_index@example.com", 36 39 ) ); 40 41 self::$user_ids[ $user[0] ] = $new_user; 37 42 } 38 43 39 $this->group_slugs['hidden'] = 'the-maw';40 $this->group_slugs['public'] = 'the-great-journey';41 $this->group_slugs['private'] = 'tsavo-highway';44 self::$group_slugs['hidden'] = 'the-maw'; 45 self::$group_slugs['public'] = 'the-great-journey'; 46 self::$group_slugs['private'] = 'tsavo-highway'; 42 47 43 48 // Create dummy groups. 44 $this->group_ids['hidden'] = $this->factory->group->create( array(45 'creator_id' => $this->user_ids['xylo'],46 'slug' => $this->group_slugs['hidden'],49 self::$group_ids['hidden'] = $factory->group->create( array( 50 'creator_id' => self::$user_ids['xylo'], 51 'slug' => self::$group_slugs['hidden'], 47 52 'status' => 'hidden', 48 53 ) ); 49 $this->group_ids['public'] = $this->factory->group->create( array(50 'creator_id' => $this->user_ids['xylo'],51 'slug' => $this->group_slugs['public'],54 self::$group_ids['public'] = $factory->group->create( array( 55 'creator_id' => self::$user_ids['xylo'], 56 'slug' => self::$group_slugs['public'], 52 57 'status' => 'public', 53 58 ) ); 54 $this->group_ids['private'] = $this->factory->group->create( array(55 'creator_id' => $this->user_ids['xylo'],56 'slug' => $this->group_slugs['private'],59 self::$group_ids['private'] = $factory->group->create( array( 60 'creator_id' => self::$user_ids['xylo'], 61 'slug' => self::$group_slugs['private'], 57 62 'status' => 'private', 58 63 ) ); 59 64 60 65 // Add dummy users to dummy hidden groups. 61 groups_join_group( $this->group_ids['hidden'], $this->user_ids['pig'] );62 groups_join_group( $this->group_ids['hidden'], $this->user_ids['alpaca red'] );66 groups_join_group( self::$group_ids['hidden'], self::$user_ids['pig'] ); 67 groups_join_group( self::$group_ids['hidden'], self::$user_ids['alpaca red'] ); 63 68 64 69 // Add dummy users to dummy public groups. 65 groups_join_group( $this->group_ids['public'], $this->user_ids['aardvark'] );66 groups_join_group( $this->group_ids['public'], $this->user_ids['alpaca red'] );67 groups_join_group( $this->group_ids['public'], $this->user_ids['cat'] );68 groups_join_group( $this->group_ids['public'], $this->user_ids['smith'] );70 groups_join_group( self::$group_ids['public'], self::$user_ids['aardvark'] ); 71 groups_join_group( self::$group_ids['public'], self::$user_ids['alpaca red'] ); 72 groups_join_group( self::$group_ids['public'], self::$user_ids['cat'] ); 73 groups_join_group( self::$group_ids['public'], self::$user_ids['smith'] ); 69 74 70 75 // Add dummy users to dummy private groups. 71 groups_join_group( $this->group_ids['private'], $this->user_ids['cat'] ); 72 groups_join_group( $this->group_ids['private'], $this->user_ids['caterpillar'] ); 76 groups_join_group( self::$group_ids['private'], self::$user_ids['cat'] ); 77 groups_join_group( self::$group_ids['private'], self::$user_ids['caterpillar'] ); 78 79 self::commit_transaction(); 73 80 } 74 81 82 public static function tearDownAfterClass() { 83 foreach ( self::$group_ids as $group_id ) { 84 groups_delete_group( $group_id ); 85 } 86 87 foreach ( self::$user_ids as $user_id ) { 88 if ( is_multisite() ) { 89 wpmu_delete_user( $user_id ); 90 } else { 91 wp_delete_user( $user_id ); 92 } 93 } 94 95 self::commit_transaction(); 96 } 75 97 76 98 /** … … 92 114 // only_friends requires authenticated requests 93 115 $suggestions = bp_core_get_suggestions( array( 94 'group_id' => $this->group_ids['public'],116 'group_id' => self::$group_ids['public'], 95 117 'only_friends' => true, 96 118 'type' => 'members', … … 103 125 public function test_suggestions_with_type_groupmembers_hidden() { 104 126 $suggestions = bp_core_get_suggestions( array( 105 'group_id' => $this->group_ids['hidden'],127 'group_id' => self::$group_ids['hidden'], 106 128 'type' => 'members', 107 129 'term' => 'pig', … … 113 135 public function test_suggestions_with_type_groupmembers_private() { 114 136 $suggestions = bp_core_get_suggestions( array( 115 'group_id' => $this->group_ids['private'],137 'group_id' => self::$group_ids['private'], 116 138 'type' => 'members', 117 139 'term' => 'cat', … … 123 145 public function test_suggestions_with_type_groupmembers_public_and_exclude_group_from_results() { 124 146 $suggestions = bp_core_get_suggestions( array( 125 'group_id' => $this->group_ids['public'],147 'group_id' => self::$group_ids['public'], 126 148 'type' => 'members', 127 149 'term' => 'smith', … … 131 153 132 154 $suggestions = bp_core_get_suggestions( array( 133 'group_id' => - $this->group_ids['public'],155 'group_id' => -self::$group_ids['public'], 134 156 'type' => 'members', 135 157 'term' => 'smith', … … 141 163 public function test_suggestions_with_type_groupmembers_private_and_exclude_group_from_results() { 142 164 $suggestions = bp_core_get_suggestions( array( 143 'group_id' => - $this->group_ids['private'],165 'group_id' => -self::$group_ids['private'], 144 166 'type' => 'members', 145 167 'term' => 'cat', … … 150 172 public function test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results() { 151 173 $suggestions = bp_core_get_suggestions( array( 152 'group_id' => $this->group_ids['hidden'],174 'group_id' => self::$group_ids['hidden'], 153 175 'type' => 'members', 154 176 'term' => 'pig',
Note: See TracChangeset
for help on using the changeset viewer.