- Timestamp:
- 06/25/2023 05:18:41 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php
r13441 r13507 229 229 230 230 /** 231 * @group enable_nav_item232 * @expectedIncorrectUsage bp_nav233 */234 public function test_enable_nav_item_true() {235 $old_options_nav = buddypress()->bp_options_nav;236 $this->set_permalink_structure( '/%postname%/' );237 238 $g = self::factory()->group->create();239 $g_obj = groups_get_group( $g );240 241 $class_name = 'BPTest_Group_Extension_Enable_Nav_Item_True';242 $e = new $class_name();243 244 $this->go_to( bp_get_group_url( $g_obj ) );245 246 $e->_register();247 248 $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );249 250 // Clean up251 buddypress()->bp_options_nav = $old_options_nav;252 }253 254 /**255 * @group enable_nav_item256 * @expectedIncorrectUsage bp_nav257 */258 public function test_enable_nav_item_false() {259 $this->set_permalink_structure( '/%postname%/' );260 $old_options_nav = buddypress()->bp_options_nav;261 262 $g = self::factory()->group->create();263 $g_obj = groups_get_group( $g );264 265 $class_name = 'BPTest_Group_Extension_Enable_Nav_Item_False';266 $e = new $class_name();267 268 $this->go_to( bp_get_group_url( $g_obj ) );269 270 $e->_register();271 272 $this->assertFalse( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );273 274 // Clean up275 buddypress()->bp_options_nav = $old_options_nav;276 }277 278 /**279 * @group visibility280 * @expectedIncorrectUsage bp_nav281 */282 public function test_visibility_private() {283 $this->set_permalink_structure( '/%postname%/' );284 $old_options_nav = buddypress()->bp_options_nav;285 $old_current_user = get_current_user_id();286 287 $g = self::factory()->group->create( array(288 'status' => 'private',289 ) );290 $g_obj = groups_get_group( $g );291 292 $class_name = 'BPTest_Group_Extension_Visibility_Private';293 $e = new $class_name();294 295 // Test as non-logged-in user296 $this->set_current_user( 0 );297 $this->go_to( bp_get_group_url( $g_obj ) );298 $e->_register();299 $this->assertFalse( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );300 301 // Clean up302 buddypress()->bp_options_nav = $old_options_nav;303 304 // Test as group member305 $u = self::factory()->user->create();306 $this->set_current_user( $u );307 $this->add_user_to_group( $u, $g );308 $this->go_to( bp_get_group_url( $g_obj ) );309 $e->_register();310 $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );311 312 // Clean up313 buddypress()->bp_options_nav = $old_options_nav;314 $this->set_current_user( $old_current_user );315 }316 317 /**318 * @group visibility319 * @expectedIncorrectUsage bp_nav320 *321 * visibility=public + status=private results in adding the item to322 * the nav. However, BP_Groups_Component::setup_globals() bounces the323 * user away from this page on a regular pageload (BP 2.0 and under)324 *325 * @see https://buddypress.trac.wordpress.org/ticket/4785326 */327 public function test_visibility_public() {328 $this->set_permalink_structure( '/%postname%/' );329 $old_options_nav = buddypress()->bp_options_nav;330 $old_current_user = get_current_user_id();331 332 $g = self::factory()->group->create( array(333 'status' => 'private',334 ) );335 $g_obj = groups_get_group( $g );336 337 $class_name = 'BPTest_Group_Extension_Visibility_Public';338 $e = new $class_name();339 340 // Test as non-logged-in user341 $this->set_current_user( 0 );342 $this->go_to( bp_get_group_url( $g_obj ) );343 $e->_register();344 $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );345 346 // Clean up347 buddypress()->bp_options_nav = $old_options_nav;348 349 // Test as group member350 $u = self::factory()->user->create();351 $this->set_current_user( $u );352 $this->add_user_to_group( $u, $g );353 $this->go_to( bp_get_group_url( $g_obj ) );354 $e->_register();355 $this->assertTrue( isset( buddypress()->bp_options_nav[ $g_obj->slug ][ $e->slug ] ) );356 357 // Clean up358 buddypress()->bp_options_nav = $old_options_nav;359 $this->set_current_user( $old_current_user );360 }361 362 /**363 231 * @group user_can_visit 364 232 */
Note: See TracChangeset
for help on using the changeset viewer.