foo = new stdClass; $bp->foo->nav = new BP_Core_Nav( 0 ); $expected = array( 'foo', 'bar' ); bp_core_new_nav_item( array( 'name' => 'Foo', 'slug' => 'foo', 'screen_function' => $expected, ), 'foo' ); bp_core_new_subnav_item( array( 'name' => 'Bar', 'slug' => 'bar', 'parent_slug' => 'foo', 'parent_url' => 'foo', 'screen_function' => $expected, ), 'foo' ); remove_filter( 'bp_is_active', array( $this, 'foo_is_active' ) ); $this->assertNotEmpty( $bp->foo->nav->get_primary( array( 'slug' => 'foo' ), false ) ); $tested = $bp->foo->nav->delete_nav( 'foo' ); $this->assertSame( $expected, reset( $tested ) ); $this->assertEmpty( $bp->foo->nav->get_primary( array( 'slug' => 'foo' ), false ) ); } /** * Helper method to filter 'bp_is_active' for unit tests. * * @param bool $retval Whether the component is active. * @param string $component Component name. */ public function foo_is_active( $retval, $component ) { if ( 'foo' === $component ) { $retval = true; } return $retval; } }