[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @group core 5 * @group nav 6 */ 7 class BP_Tests_Core_Nav_BpCoreRemoveSubnavItem extends BP_UnitTestCase { 8 /** 9 * @expectedIncorrectUsage bp_nav 10 */ 11 public function test_should_remove_subnav_item() { 12 $bp = buddypress(); 13 14 $_bp_nav = $bp->bp_nav; 15 $_bp_options_nav = $bp->bp_options_nav; 16 17 bp_core_new_nav_item( array( 18 'name' => 'Foo', 19 'slug' => 'foo', 20 'screen_function' => 'foo', 21 ) ); 22 23 bp_core_new_subnav_item( array( 24 'name' => 'Bar', 25 'slug' => 'bar', 26 'parent_slug' => 'foo', 27 'parent_url' => 'foo', 28 'screen_function' => 'bar', 29 ) ); 30 31 $this->assertTrue( isset( $bp->bp_options_nav['foo']['bar'] ) ); 32 33 bp_core_remove_subnav_item( 'foo', 'bar' ); 34 35 $this->assertFalse( isset( $bp->bp_options_nav['foo']['bar'] ) ); 36 37 $bp->bp_nav = $_bp_nav; 38 $bp->bp_options_nav = $_bp_options_nav; 39 } 40 41 /** 42 * @expectedIncorrectUsage bp_nav 43 */ 44 public function test_should_fail_on_incorrect_parent() { 45 $bp = buddypress(); 46 47 $_bp_nav = $bp->bp_nav; 48 $_bp_options_nav = $bp->bp_options_nav; 49 50 bp_core_new_nav_item( array( 51 'name' => 'Foo', 52 'slug' => 'foo', 53 'screen_function' => 'foo', 54 ) ); 55 56 bp_core_new_subnav_item( array( 57 'name' => 'Bar', 58 'slug' => 'bar', 59 'parent_slug' => 'foo', 60 'parent_url' => 'foo', 61 'screen_function' => 'bar', 62 ) ); 63 64 $this->assertTrue( isset( $bp->bp_options_nav['foo']['bar'] ) ); 65 66 bp_core_remove_subnav_item( 'bad-parent', 'bar' ); 67 68 $this->assertTrue( isset( $bp->bp_options_nav['foo']['bar'] ) ); 69 70 $bp->bp_nav = $_bp_nav; 71 $bp->bp_options_nav = $_bp_options_nav; 72 } 73 74 public function test_backcompat_remove_group_nav_items() { 75 $g1 = self::factory()->group->create(); 76 77 // In group context 78 $g_obj = groups_get_group( $g1 ); 79 $this->go_to( bp_get_group_permalink( $g_obj ) ); 80 81 bp_core_new_subnav_item( array( 82 'name' => 'Clam', 83 'slug' => 'clam', 84 'parent_slug' => bp_get_current_group_slug(), 85 'parent_url' => bp_get_group_permalink( $g_obj ), 86 'screen_function' => 'clam_subnav', 87 ) ); 88 89 bp_core_remove_subnav_item( $g_obj->slug, 'clam' ); 90 91 $nav = bp_get_nav_menu_items( 'groups' ); 92 $found = false; 93 foreach ( $nav as $_nav ) { 94 if ( 'clam' === $_nav->css_id ) { 95 $found = true; 96 break; 97 } 98 } 99 100 $this->assertFalse( $found ); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |