| | 67 | |
| | 68 | public function foo_is_active( $retval, $component ) { |
| | 69 | if ( 'foo' === $component ) { |
| | 70 | $retval = true; |
| | 71 | } |
| | 72 | |
| | 73 | return $retval; |
| | 74 | } |
| | 75 | /** |
| | 76 | * @ticket BP7203 |
| | 77 | */ |
| | 78 | public function test_remove_subnav_item_array_as_screen_function() { |
| | 79 | $bp = buddypress(); |
| | 80 | |
| | 81 | add_filter( 'bp_is_active', array( $this, 'foo_is_active' ), 10, 2 ); |
| | 82 | |
| | 83 | $bp->foo = new stdClass; |
| | 84 | $bp->foo->nav = new BP_Core_Nav( 0 ); |
| | 85 | |
| | 86 | $expected = array( 'foo', 'bar' ); |
| | 87 | |
| | 88 | bp_core_new_nav_item( array( |
| | 89 | 'name' => 'Foo', |
| | 90 | 'slug' => 'foo', |
| | 91 | 'screen_function' => $expected, |
| | 92 | ), 'foo' ); |
| | 93 | |
| | 94 | bp_core_new_subnav_item( array( |
| | 95 | 'name' => 'Bar', |
| | 96 | 'slug' => 'bar', |
| | 97 | 'parent_slug' => 'foo', |
| | 98 | 'parent_url' => 'foo', |
| | 99 | 'screen_function' => $expected, |
| | 100 | ), 'foo' ); |
| | 101 | |
| | 102 | remove_filter( 'bp_is_active', array( $this, 'foo_is_active' ), 10, 2 ); |
| | 103 | |
| | 104 | $this->assertNotEmpty( $bp->foo->nav->get_primary( array( 'slug' => 'foo' ), false ) ); |
| | 105 | |
| | 106 | $tested = $bp->foo->nav->delete_nav( 'foo' ); |
| | 107 | $this->assertSame( $expected, reset( $tested ) ); |
| | 108 | |
| | 109 | $this->assertEmpty( $bp->foo->nav->get_primary( array( 'slug' => 'foo' ), false ) ); |
| | 110 | } |