- Timestamp:
- 05/03/2023 06:18:23 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/nav/bpCoreNewSubnavItem.php
r13449 r13468 349 349 } 350 350 351 public function screen_callback() { 352 bp_core_load_template( 'members/single/plugins' ); 353 } 354 355 public function new_nav_hook() { 356 bp_core_new_subnav_item( 357 array( 358 'name' => 'Testing', 359 'slug' => 'testing', 360 'parent_slug' => bp_get_profile_slug(), 361 'screen_function' => array( $this, 'screen_callback' ), 362 'position' => 20 363 ) 364 ); 365 } 366 351 367 /** 352 368 * @ticket BP7931 353 369 */ 354 370 public function test_subnav_should_not_404_on_early_bp_setup_nav_priority() { 371 // Register a subnav on 'bp_setup_nav' hook early (at priority zero). 372 add_action( 'bp_setup_nav', array( $this, 'screen_callback' ), 0 ); 373 355 374 $u = self::factory()->user->create(); 356 375 $old_current_user = get_current_user_id(); 357 376 $this->set_current_user( $u ); 358 377 359 $user_domain = bp_members_get_user_url( $u ); 360 361 // Register a subnav on 'bp_setup_nav' hook early (at priority zero). 362 add_action( 'bp_setup_nav', function() use ( $user_domain ) { 363 /* 364 * Emulate a subnav screen. 365 * 366 * The bp_core_load_template() call is imperative for our 404 check to work! 367 */ 368 $screen = function() { 369 bp_core_load_template ('members/single/plugins'); 370 }; 371 372 // Register the subnav. 373 bp_core_new_subnav_item( array ( 374 'name' => 'Testing', 375 'slug' => 'testing', 376 'parent_url' => $user_domain . bp_get_profile_slug (). '/', 377 'parent_slug' => bp_get_profile_slug (), 378 'screen_function' => $screen, 379 'position' => 20 380 ) ); 381 }, 0 ); 378 $url = bp_members_get_user_url( 379 $u, 380 array( 381 'single_item_component' => bp_get_profile_slug(), 382 'single_item_action' => 'testing', 383 ) 384 ); 382 385 383 386 // Emulate visit to our new subnav page. 384 $this->go_to( $u ser_domain . bp_get_profile_slug () . '/testing/');387 $this->go_to( $url ); 385 388 386 389 // Assert that subnav page does not 404. 387 390 $this->assertFalse( is_404() ); 388 391 392 remove_action( 'bp_setup_nav', array( $this, 'screen_callback' ), 0 ); 393 389 394 $this->set_current_user( $old_current_user ); 390 395 }
Note: See TracChangeset
for help on using the changeset viewer.