Ticket #4017: 4017.04-tests.diff
File 4017.04-tests.diff, 20.1 KB (added by , 9 years ago) |
---|
-
tests/phpunit/testcases/groups/class-bp-groups-group.php
diff --git tests/phpunit/testcases/groups/class-bp-groups-group.php tests/phpunit/testcases/groups/class-bp-groups-group.php index 489fd3c..2c09487 100644
class BP_Tests_BP_Groups_Group_TestCases extends BP_UnitTestCase { 1029 1029 1030 1030 $this->set_current_user( $old_user ); 1031 1031 } 1032 1033 /** 1034 * @group group_types 1035 */ 1036 public function test_group_type_single_value() { 1037 $g1 = $this->factory->group->create(); 1038 $g2 = $this->factory->group->create(); 1039 groups_register_type( 'foo' ); 1040 groups_register_type( 'bar' ); 1041 groups_set_type( $g1, 'foo' ); 1042 groups_set_type( $g2, 'bar' ); 1043 1044 $groups = BP_Groups_Group::get( array( 1045 'group_type' => 'foo', 1046 ) ); 1047 1048 $found = wp_list_pluck( $groups['groups'], 'id' ); 1049 $this->assertEquals( array( $g1 ), $found ); 1050 } 1051 1052 /** 1053 * @group group_types 1054 */ 1055 public function test_group_type_array_with_single_value() { 1056 $g1 = $this->factory->group->create(); 1057 $g2 = $this->factory->group->create(); 1058 groups_register_type( 'foo' ); 1059 groups_register_type( 'bar' ); 1060 groups_set_type( $g1, 'foo' ); 1061 groups_set_type( $g2, 'bar' ); 1062 1063 $groups = BP_Groups_Group::get( array( 1064 'group_type' => array( 'foo' ), 1065 ) ); 1066 1067 $found = wp_list_pluck( $groups['groups'], 'id' ); 1068 $this->assertEquals( array( $g1 ), $found ); 1069 } 1070 1071 /** 1072 * @group group_types 1073 */ 1074 public function test_group_type_with_comma_separated_list() { 1075 $g1 = $this->factory->group->create(); 1076 $g2 = $this->factory->group->create(); 1077 groups_register_type( 'foo' ); 1078 groups_register_type( 'bar' ); 1079 groups_set_type( $g1, 'foo' ); 1080 groups_set_type( $g2, 'bar' ); 1081 1082 $groups = BP_Groups_Group::get( array( 1083 'group_type' => 'foo, bar', 1084 ) ); 1085 1086 $found = wp_list_pluck( $groups['groups'], 'id' ); 1087 $this->assertEqualSets( array( $g1, $g2 ), $found ); 1088 } 1089 1090 /** 1091 * @group group_types 1092 */ 1093 public function test_group_type_array_with_multiple_values() { 1094 $g1 = $this->factory->group->create(); 1095 $g2 = $this->factory->group->create(); 1096 groups_register_type( 'foo' ); 1097 groups_register_type( 'bar' ); 1098 groups_set_type( $g1, 'foo' ); 1099 groups_set_type( $g2, 'bar' ); 1100 1101 $groups = BP_Groups_Group::get( array( 1102 'group_type' => array( 'foo', 'bar' ), 1103 ) ); 1104 1105 $found = wp_list_pluck( $groups['groups'], 'id' ); 1106 $this->assertEqualSets( array( $g1, $g2 ), $found ); 1107 } 1108 1109 /** 1110 * @group group_types 1111 */ 1112 public function test_group_type_should_discart_non_existing_types_in_comma_separated_value() { 1113 $g1 = $this->factory->group->create(); 1114 $g2 = $this->factory->group->create(); 1115 groups_register_type( 'foo' ); 1116 groups_register_type( 'bar' ); 1117 groups_set_type( $g1, 'foo' ); 1118 groups_set_type( $g2, 'bar' ); 1119 1120 $groups = BP_Groups_Group::get( array( 1121 'group_type' => 'foo, baz', 1122 ) ); 1123 1124 $found = wp_list_pluck( $groups['groups'], 'id' ); 1125 $this->assertEquals( array( $g1 ), $found ); 1126 } 1127 1128 /** 1129 * @group group_types 1130 */ 1131 public function test_group_type_should_return_empty_when_no_groups_match_specified_types() { 1132 $g1 = $this->factory->group->create(); 1133 $g2 = $this->factory->group->create(); 1134 1135 $groups = BP_Groups_Group::get( array( 1136 'group_type' => 'foo, baz', 1137 ) ); 1138 1139 $this->assertEmpty( $groups['groups'] ); 1140 } 1141 1142 /** 1143 * @group group_types 1144 */ 1145 public function test_group_type__in_single_value() { 1146 $g1 = $this->factory->group->create(); 1147 $g2 = $this->factory->group->create(); 1148 groups_register_type( 'foo' ); 1149 groups_register_type( 'bar' ); 1150 groups_set_type( $g1, 'foo' ); 1151 groups_set_type( $g2, 'bar' ); 1152 1153 $groups = BP_Groups_Group::get( array( 1154 'group_type__in' => 'bar', 1155 ) ); 1156 1157 $found = wp_list_pluck( $groups['groups'], 'id' ); 1158 $this->assertEquals( array( $g2 ), $found ); 1159 } 1160 1161 /** 1162 * @group group_types 1163 */ 1164 public function test_group_type__in_comma_separated_values() { 1165 $g1 = $this->factory->group->create(); 1166 $g2 = $this->factory->group->create(); 1167 groups_register_type( 'foo' ); 1168 groups_register_type( 'bar' ); 1169 groups_set_type( $g1, 'foo' ); 1170 groups_set_type( $g2, 'bar' ); 1171 1172 $groups = BP_Groups_Group::get( array( 1173 'group_type__in' => 'foo, bar', 1174 ) ); 1175 1176 $found = wp_list_pluck( $groups['groups'], 'id' ); 1177 $this->assertEqualSets( array( $g1, $g2 ), $found ); 1178 } 1179 1180 /** 1181 * @group group_types 1182 */ 1183 public function test_group_type__in_array_multiple_values() { 1184 $g1 = $this->factory->group->create(); 1185 $g2 = $this->factory->group->create(); 1186 groups_register_type( 'foo' ); 1187 groups_register_type( 'bar' ); 1188 groups_set_type( $g1, 'foo' ); 1189 groups_set_type( $g2, 'bar' ); 1190 1191 $groups = BP_Groups_Group::get( array( 1192 'group_type__in' => array( 'foo', 'bar' ), 1193 ) ); 1194 1195 $found = wp_list_pluck( $groups['groups'], 'id' ); 1196 $this->assertEqualSets( array( $g1, $g2 ), $found ); 1197 } 1198 1199 /** 1200 * @group group_types 1201 */ 1202 public function test_group_type__in_array_with_single_value() { 1203 $g1 = $this->factory->group->create(); 1204 $g2 = $this->factory->group->create(); 1205 groups_register_type( 'foo' ); 1206 groups_register_type( 'bar' ); 1207 groups_set_type( $g1, 'foo' ); 1208 groups_set_type( $g2, 'bar' ); 1209 1210 $groups = BP_Groups_Group::get( array( 1211 'group_type__in' => array( 'foo' ), 1212 ) ); 1213 1214 $found = wp_list_pluck( $groups['groups'], 'id' ); 1215 $this->assertEquals( array( $g1 ), $found ); 1216 } 1217 1218 /** 1219 * @group group_types 1220 */ 1221 public function test_group_type__in_should_discart_non_existing_types_in_comma_separated_value() { 1222 $g1 = $this->factory->group->create(); 1223 $g2 = $this->factory->group->create(); 1224 groups_register_type( 'foo' ); 1225 groups_register_type( 'bar' ); 1226 groups_set_type( $g1, 'foo' ); 1227 groups_set_type( $g2, 'bar' ); 1228 1229 $groups = BP_Groups_Group::get( array( 1230 'group_type__in' => 'foo, baz', 1231 ) ); 1232 1233 $found = wp_list_pluck( $groups['groups'], 'id' ); 1234 $this->assertEquals( array( $g1 ), $found ); 1235 } 1236 1237 /** 1238 * @group group_types 1239 */ 1240 public function test_group_type__in_should_return_empty_when_no_groups_match_specified_types() { 1241 $g1 = $this->factory->group->create(); 1242 $g2 = $this->factory->group->create(); 1243 1244 $groups = BP_Groups_Group::get( array( 1245 'group_type__in' => 'foo, baz', 1246 ) ); 1247 1248 $this->assertEmpty( $groups['groups'] ); 1249 } 1250 1251 /** 1252 * @group group_types 1253 */ 1254 public function test_group_type_should_take_precedence_over_group_type__in() { 1255 $g1 = $this->factory->group->create(); 1256 $g2 = $this->factory->group->create(); 1257 groups_register_type( 'foo' ); 1258 groups_register_type( 'bar' ); 1259 groups_set_type( $g1, 'foo' ); 1260 groups_set_type( $g2, 'bar' ); 1261 1262 $groups = BP_Groups_Group::get( array( 1263 'group_type__in' => 'foo', 1264 'group_type' => 'bar', 1265 ) ); 1266 1267 $found = wp_list_pluck( $groups['groups'], 'id' ); 1268 $this->assertEquals( array( $g2 ), $found ); 1269 } 1270 1271 /** 1272 * @group group_types 1273 */ 1274 public function test_group_type__not_in_should_return_groups_with_types_and_without_types() { 1275 $g1 = $this->factory->group->create(); 1276 $g2 = $this->factory->group->create(); 1277 $g3 = $this->factory->group->create(); 1278 groups_register_type( 'foo' ); 1279 groups_register_type( 'bar' ); 1280 groups_set_type( $g1, 'foo' ); 1281 groups_set_type( $g2, 'bar' ); 1282 1283 $groups = BP_Groups_Group::get( array( 1284 'group_type__not_in' => 'foo', 1285 ) ); 1286 1287 $found = wp_list_pluck( $groups['groups'], 'id' ); 1288 $this->assertEquals( array( $g2, $g3 ), $found ); 1289 } 1290 1291 /** 1292 * @group group_types 1293 */ 1294 public function test_group_type__not_in_comma_separated_values() { 1295 $g1 = $this->factory->group->create(); 1296 $g2 = $this->factory->group->create(); 1297 $g3 = $this->factory->group->create(); 1298 groups_register_type( 'foo' ); 1299 groups_register_type( 'bar' ); 1300 groups_set_type( $g1, 'foo' ); 1301 groups_set_type( $g2, 'bar' ); 1302 groups_set_type( $g3, 'baz' ); 1303 1304 $groups = BP_Groups_Group::get( array( 1305 'group_type__not_in' => 'foo, bar', 1306 ) ); 1307 1308 $found = wp_list_pluck( $groups['groups'], 'id' ); 1309 $this->assertEquals( array( $g3 ), $found ); 1310 } 1311 1312 /** 1313 * @group group_types 1314 */ 1315 public function test_group_type__not_array_with_multiple_values() { 1316 $g1 = $this->factory->group->create(); 1317 $g2 = $this->factory->group->create(); 1318 $g3 = $this->factory->group->create(); 1319 groups_register_type( 'foo' ); 1320 groups_register_type( 'bar' ); 1321 groups_set_type( $g1, 'foo' ); 1322 groups_set_type( $g2, 'bar' ); 1323 groups_set_type( $g3, 'baz' ); 1324 1325 $groups = BP_Groups_Group::get( array( 1326 'group_type__not_in' => array( 'foo', 'bar' ), 1327 ) ); 1328 1329 $found = wp_list_pluck( $groups['groups'], 'id' ); 1330 $this->assertEquals( array( $g3 ), $found ); 1331 } 1332 1333 /** 1334 * @group group_types 1335 */ 1336 public function test_group_type__not_in_should_return_no_results_when_all_groups_mathc_sepecified_type() { 1337 $g1 = $this->factory->group->create(); 1338 $g2 = $this->factory->group->create(); 1339 $g3 = $this->factory->group->create(); 1340 groups_register_type( 'foo' ); 1341 groups_set_type( $g1, 'foo' ); 1342 groups_set_type( $g2, 'foo' ); 1343 groups_set_type( $g3, 'foo' ); 1344 1345 $groups = BP_Groups_Group::get( array( 1346 'group_type__not_in' => 'foo', 1347 ) ); 1348 1349 $this->assertEmpty( $groups['groups'] ); 1350 } 1351 1352 /** 1353 * @group group_types 1354 */ 1355 public function test_group_type__not_in_takes_precedence_over_group_type() { 1356 $g1 = $this->factory->group->create(); 1357 $g2 = $this->factory->group->create(); 1358 $g3 = $this->factory->group->create(); 1359 groups_register_type( 'foo' ); 1360 groups_set_type( $g1, 'foo' ); 1361 groups_set_type( $g2, 'foo' ); 1362 groups_set_type( $g3, 'foo' ); 1363 1364 $groups = BP_Groups_Group::get( array( 1365 'group_type' => 'foo', 1366 'group_type__not_in' => 'foo', 1367 ) ); 1368 1369 $this->assertEmpty( $groups['groups'] ); 1370 } 1032 1371 } 1033 1372 1034 1373 /** -
new file tests/phpunit/testcases/groups/types.php
diff --git tests/phpunit/testcases/groups/types.php tests/phpunit/testcases/groups/types.php new file mode 100644 index 0000000..6734fbe
- + 1 <?php 2 3 /** 4 * @group groups 5 * @group group_types 6 */ 7 class BP_Tests_Groups_Types extends BP_UnitTestCase { 8 protected $u1 = null; 9 10 public function setUp() { 11 parent::setUp(); 12 13 buddypress()->groups->types = array(); 14 15 $this->u1 = $this->factory->user->create(); 16 } 17 18 public function test_groups_register_type_should_fail_for_existing_group_type() { 19 groups_register_type( 'foo' ); 20 $this->assertWPError( groups_register_type( 'foo' ) ); 21 } 22 23 public function test_groups_register_type_should_sanitize_group_type_key() { 24 $key = 'F//oo% -Bar'; 25 $sanitized_key = 'foo-bar'; 26 27 $object = groups_register_type( $key ); 28 $this->assertSame( $sanitized_key, $object->name ); 29 } 30 31 public function test_groups_register_type_should_store_group_type_string_as_name_property() { 32 $object = groups_register_type( 'foo' ); 33 $this->assertSame( 'foo', $object->name ); 34 } 35 36 public function test_groups_register_type_should_fill_missing_labels_with_ucfirst_group_type() { 37 $object = groups_register_type( 'foo' ); 38 foreach ( $object->labels as $label ) { 39 $this->assertSame( 'Foo', $label ); 40 } 41 } 42 43 public function test_groups_register_type_should_respect_custom_name_labels() { 44 $object = groups_register_type( 'foo', array( 45 'labels' => array( 46 'name' => 'Bar', 47 ), 48 ) ); 49 50 $this->assertSame( 'Bar', $object->labels['name'] ); 51 $this->assertSame( 'Bar', $object->labels['singular_name'] ); 52 } 53 54 public function test_groups_register_type_should_respect_custom_singular_name_labels() { 55 $object = groups_register_type( 'foo', array( 56 'labels' => array( 57 'singular_name' => 'Bar', 58 ), 59 ) ); 60 61 $this->assertSame( 'Foo', $object->labels['name'] ); 62 $this->assertSame( 'Bar', $object->labels['singular_name'] ); 63 } 64 65 public function test_groups_register_type_has_directory_should_default_to_true() { 66 $object = groups_register_type( 'foo' ); 67 68 $this->assertTrue( $object->has_directory ); 69 $this->assertSame( 'foo', $object->directory_slug ); 70 } 71 72 public function test_groups_register_type_has_directory_true() { 73 $object = groups_register_type( 'foo', array( 74 'has_directory' => true, 75 ) ); 76 77 $this->assertTrue( $object->has_directory ); 78 $this->assertSame( 'foo', $object->directory_slug ); 79 } 80 81 public function test_groups_register_type_has_directory_false() { 82 $object = groups_register_type( 'foo', array( 83 'has_directory' => false, 84 ) ); 85 86 $this->assertFalse( $object->has_directory ); 87 $this->assertSame( '', $object->directory_slug ); 88 } 89 90 public function test_groups_register_type_should_store_has_directory_string() { 91 $object = groups_register_type( 'foo', array( 92 'has_directory' => 'foos', 93 ) ); 94 95 $this->assertTrue( $object->has_directory ); 96 $this->assertSame( 'foos', $object->directory_slug ); 97 } 98 99 public function test_groups_get_type_object_should_return_null_for_non_existing_group_type() { 100 $this->assertSame( null, groups_get_type_object( 'foo' ) ); 101 } 102 103 public function test_groups_get_type_object_should_return_type_object() { 104 groups_register_type( 'foo' ); 105 $this->assertInternalType( 'object', groups_get_type_object( 'foo' ) ); 106 } 107 108 public function test_groups_type_exists_shoud_return_false_when_group_type_is_empty() { 109 $this->assertFalse( groups_type_exists( '' ) ); 110 } 111 112 public function test_groups_type_exists_should_return_false_for_non_existing_group_type() { 113 $this->assertFalse( groups_type_exists( 'foo' ) ); 114 } 115 116 public function test_groups_type_exists_should_return_false_for_non_existing_group_types_array() { 117 $this->assertFalse( groups_type_exists( array( 'foo', 'bar' ) ) ); 118 } 119 120 public function test_groups_type_exists_should_only_return_array_of_registered_group_types() { 121 groups_register_type( 'foo' ); 122 groups_register_type( 'bar' ); 123 124 $this->assertSame( array( 'foo' ), groups_type_exists( array( 'foo', 'baz' ) ) ); 125 } 126 127 public function test_groups_set_type_should_return_false_for_invalid_group_type() { 128 $this->assertFalse( groups_set_type( 1, 'foo' ) ); 129 } 130 131 public function test_groups_set_type_success() { 132 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 133 groups_register_type( 'foo' ); 134 135 $this->assertNotEmpty( groups_set_type( $g, 'foo' ) ); 136 } 137 138 public function test_groups_set_type_when_group_types_is_array() { 139 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 140 groups_register_type( 'foo' ); 141 groups_register_type( 'bar' ); 142 groups_set_type( $g, array( 'foo', 'bar' ) ); 143 144 $this->assertEqualSets( array( 'foo', 'bar' ), groups_get_type( $g, false ) ); 145 } 146 147 public function test_groups_set_type_when_group_types_array_contains_only_one_valid() { 148 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 149 groups_register_type( 'foo' ); 150 groups_set_type( $g, array( 'foo', 'bar' ) ); 151 152 $this->assertSame( array( 'foo' ), groups_get_type( $g, false ) ); 153 } 154 155 public function test_groups_set_type_should_remove_type_when_passing_an_empty_value() { 156 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 157 groups_register_type( 'foo' ); 158 groups_set_type( $g, 'foo' ); 159 160 // Make sure group type is set. 161 $this->assertSame( 'foo', groups_get_type( $g ) ); 162 163 $this->assertSame( array(), groups_set_type( $g, '' ) ); 164 $this->assertFalse( groups_get_type( $g ) ); 165 } 166 167 public function test_groups_get_type_with_default_value_for_single() { 168 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 169 groups_register_type( 'foo' ); 170 groups_register_type( 'bar' ); 171 groups_set_type( $g, 'foo' ); 172 groups_set_type( $g, 'bar', true ); 173 174 $this->assertSame( 'foo', groups_get_type( $g ) ); 175 } 176 177 public function test_groups_get_type_with_single_true() { 178 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 179 groups_register_type( 'foo' ); 180 groups_register_type( 'bar' ); 181 groups_set_type( $g, 'foo' ); 182 groups_set_type( $g, 'bar', true ); 183 184 $this->assertSame( 'foo', groups_get_type( $g, true ) ); 185 } 186 187 public function test_groups_get_type_with_single_false() { 188 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 189 groups_register_type( 'foo' ); 190 groups_register_type( 'bar' ); 191 groups_set_type( $g, 'foo' ); 192 groups_set_type( $g, 'bar', true ); 193 194 $this->assertEqualSets( array( 'foo', 'bar' ), groups_get_type( $g, false ) ); 195 } 196 197 public function test_groups_get_type_should_return_false_when_no_value_is_found() { 198 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 199 groups_register_type( 'foo' ); 200 201 $this->assertFalse( groups_get_type( $g ) ); 202 } 203 204 public function test_groups_remove_type_should_return_false_when_group_type_is_empty() { 205 $this->assertFalse( groups_remove_type( 9, '' ) ); 206 } 207 208 public function test_groups_remove_type_should_return_false_when_group_type_is_invalid() { 209 $this->assertFalse( groups_remove_type( 9, 'foo' ) ); 210 } 211 212 public function test_groups_remove_type_should_return_false_when_group_is_not_of_provided_type() { 213 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 214 groups_register_type( 'foo' ); 215 groups_register_type( 'bar' ); 216 groups_set_type( $g, 'foo' ); 217 218 $this->assertFalse( groups_remove_type( $g, 'bar' ) ); 219 $this->assertEquals( array( 'foo' ), groups_get_type( $g, false ) ); 220 } 221 222 public function tests_groups_remove_type_should_return_true_on_successful_deletion() { 223 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 224 groups_register_type( 'foo' ); 225 groups_register_type( 'bar' ); 226 groups_set_type( $g, 'foo' ); 227 groups_set_type( $g, 'bar', true ); 228 229 $this->assertTrue( groups_remove_type( $g, 'foo' ) ); 230 $this->assertEquals( array( 'bar' ), groups_get_type( $g, false ) ); 231 } 232 233 public function tests_groups_remove_type_should_return_true_on_successful_when_types_is_array() { 234 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 235 groups_register_type( 'foo' ); 236 groups_register_type( 'bar' ); 237 groups_set_type( $g, array( 'foo', 'bar' ) ); 238 239 $this->assertTrue( groups_remove_type( $g, array( 'foo', 'bar' ) ) ); 240 } 241 242 public function tests_groups_remove_type_should_remove_only_valid_type_when_array_is_passed() { 243 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 244 groups_register_type( 'foo' ); 245 groups_register_type( 'bar' ); 246 groups_set_type( $g, array( 'foo', 'bar' ) ); 247 248 $this->assertTrue( groups_remove_type( $g, array( 'foo', 'baz' ) ) ); 249 $this->assertEquals( array( 'bar' ), groups_get_type( $g, false ) ); 250 } 251 252 public function test_groups_has_type_should_return_false_when_group_type_is_empty() { 253 $this->assertFalse( groups_has_type( 9, '' ) ); 254 } 255 256 public function test_groups_has_type_should_return_false_when_group_type_is_invalid() { 257 $this->assertFalse( groups_has_type( 9, 'foo' ) ); 258 } 259 260 public function test_groups_has_type_should_return_false_when_group_id_is_empty() { 261 groups_register_type( 'foo' ); 262 263 $this->assertFalse( groups_has_type( '', 'foo' ) ); 264 } 265 266 public function test_groups_has_type_should_return_false_when_group_is_not_of_provided_type() { 267 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 268 groups_register_type( 'foo' ); 269 groups_register_type( 'bar' ); 270 groups_set_type( $g, 'foo' ); 271 272 $this->assertFalse( groups_has_type( $g, 'bar' ) ); 273 } 274 275 public function test_groups_has_type_should_return_true_on_success() { 276 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 277 groups_register_type( 'foo' ); 278 groups_register_type( 'bar' ); 279 groups_set_type( $g, 'foo' ); 280 groups_set_type( $g, 'bar', true ); 281 282 $this->assertTrue( groups_has_type( $g, 'foo' ) ); 283 $this->assertEqualSets( array( 'bar', 'foo' ), groups_get_type( $g, false ) ); 284 } 285 286 /** 287 * @group cache 288 */ 289 public function test_groups_get_type_should_hit_cache() { 290 $g = $this->factory->group->create( array( 'creator_id' => $this->u1 ) ); 291 groups_register_type( 'foo' ); 292 groups_set_type( $g, 'foo' ); 293 294 global $wpdb; 295 296 // Initial query. Should hit DB. 297 groups_get_type( $g ); 298 $num_queries = $wpdb->num_queries; 299 300 // Next query should hit cache 301 groups_get_type( $g ); 302 $this->assertSame( $num_queries, $wpdb->num_queries ); 303 } 304 } 305 No newline at end of file