- Timestamp:
- 08/22/2021 03:16:06 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php
r12430 r13086 16 16 } 17 17 18 /** 19 * @group __construct 20 * @expectedDeprecated BP_Groups_Group::__construct 21 */ 22 public function test_deprecated_arg() { 23 $group = new BP_Groups_Group( 123456789, array( 'populate_extras' => true ) ); 24 $this->assertSame( 0, $group->id ); 25 } 26 18 27 /** get() ************************************************************/ 28 29 /** 30 * @group get 31 */ 32 public function test_get_group_id_with_slug() { 33 $slug = 'group-test'; 34 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 35 $group_id = BP_Groups_Group::group_exists( $slug ); 36 37 $this->assertSame( $g1, $group_id ); 38 } 39 40 /** 41 * @group get 42 */ 43 public function test_get_group_id_with_empty_slug() { 44 $this->assertFalse( BP_Groups_Group::group_exists( '' ) ); 45 } 46 47 /** 48 * @group get 49 */ 50 public function test_get_group_id_from_slug_with_empty_slug() { 51 $this->assertFalse( BP_Groups_Group::get_id_from_slug( '' ) ); 52 } 53 54 /** 55 * @group get 56 */ 57 public function test_get_group_id_from_slug() { 58 $slug = 'group-test'; 59 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 60 $group_id = BP_Groups_Group::get_id_from_slug( $slug ); 61 62 $this->assertSame( $g1, $group_id ); 63 } 64 65 /** 66 * @group get 67 * @expectedDeprecated BP_Groups_Group::group_exists 68 */ 69 public function test_get_group_with_slug_with_deprecated_args() { 70 $slug = 'group-test'; 71 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 72 $group_id = BP_Groups_Group::group_exists( $slug, 'random-name' ); 73 74 $this->assertSame( $g1, $group_id ); 75 } 19 76 20 77 /** … … 1144 1201 1145 1202 $groups = BP_Groups_Group::search_groups( "'tis " ); 1146 1147 $found = wp_list_pluck( $groups['groups'], 'group_id' ); 1203 $found = wp_list_pluck( $groups['groups'], 'group_id' ); 1148 1204 1149 1205 $this->assertEquals( array( $g1 ), $found ); 1206 $this->assertNotContains( $g2, $found ); 1207 } 1208 1209 /** 1210 * @expectedDeprecated BP_Groups_Group::get_by_letter 1211 */ 1212 public function test_get_by_letter_with_deprecated_arg() { 1213 $g1 = self::factory()->group->create( array( 1214 'name' => 'Awesome Cool Group', 1215 'description' => 'Neat', 1216 ) ); 1217 $g2 = self::factory()->group->create(); 1218 1219 $groups = BP_Groups_Group::get_by_letter( 'A', null, null, false ); 1220 $found = wp_list_pluck( $groups['groups'], 'id' ); 1221 1222 $this->assertEquals( array( $g1 ), $found ); 1223 $this->assertNotContains( $g2, $found ); 1150 1224 } 1151 1225 1152 1226 public function test_get_by_letter_typical_use() { 1227 $g1 = self::factory()->group->create( array( 1228 'name' => 'Awesome Cool Group', 1229 'description' => 'Neat', 1230 ) ); 1231 $g2 = self::factory()->group->create(); 1232 1233 $groups = BP_Groups_Group::get_by_letter( 'A' ); 1234 $found = wp_list_pluck( $groups['groups'], 'id' ); 1235 1236 $this->assertEquals( array( $g1 ), $found ); 1237 $this->assertNotContains( $g2, $found ); 1238 } 1239 1240 public function test_get_by_letter_with_exclude() { 1153 1241 $g1 = self::factory()->group->create( array( 1154 1242 'name' => 'Awesome Cool Group', … … 1156 1244 ) ); 1157 1245 $g2 = self::factory()->group->create( array( 1158 'name' => 'Babylon Kong',1159 'description' => 'Awesome',1160 ) );1161 1162 $groups = BP_Groups_Group::get_by_letter( 'A' );1163 1164 $found = wp_list_pluck( $groups['groups'], 'id' );1165 1166 $this->assertEquals( array( $g1 ), $found );1167 1168 }1169 1170 public function test_get_by_letter_with_exclude() {1171 $g1 = self::factory()->group->create( array(1172 'name' => 'Awesome Cool Group',1173 'description' => 'Neat',1174 ) );1175 $g2 = self::factory()->group->create( array(1176 1246 'name' => 'Another Cool Group', 1177 1247 'description' => 'Awesome', … … 1179 1249 1180 1250 $groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1, 'stringthatshouldberemoved' ) ); 1181 1182 $found = wp_list_pluck( $groups['groups'], 'id' ); 1251 $found = wp_list_pluck( $groups['groups'], 'id' ); 1183 1252 1184 1253 $this->assertEquals( array( $g2 ), $found ); … … 1210 1279 } 1211 1280 1281 /** 1282 * @expectedDeprecated BP_Groups_Group::get_random 1283 */ 1284 public function test_get_random_with_deprecated_arg() { 1285 $g1 = self::factory()->group->create(); 1286 $g2 = self::factory()->group->create(); 1287 1288 // There are only two groups, so excluding one should give us the other 1289 $groups = BP_Groups_Group::get_random( null, null, 0, false, false, array( $g1, 'ignore this' ) ); 1290 $found = wp_list_pluck( $groups['groups'], 'id' ); 1291 1292 $this->assertEquals( array( $g2 ), $found ); 1293 } 1294 1212 1295 public function test_get_random_with_exclude() { 1213 1296 $g1 = self::factory()->group->create(); … … 1232 1315 // Only one group will match, so the random part doesn't matter 1233 1316 $groups = BP_Groups_Group::get_random( null, null, 0, 'daci' ); 1234 1235 $found = wp_list_pluck( $groups['groups'], 'id' ); 1317 $found = wp_list_pluck( $groups['groups'], 'id' ); 1236 1318 1237 1319 $this->assertEquals( array( $g1 ), $found ); 1320 $this->assertNotContains( $g2, $found ); 1238 1321 } 1239 1322
Note: See TracChangeset
for help on using the changeset viewer.