- Timestamp:
- 06/25/2023 05:18:41 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/nav/bpCoreNewNavItem.php
r13441 r13507 16 16 17 17 parent::tear_down(); 18 }19 20 /**21 * @expectedIncorrectUsage bp_nav22 */23 public function test_user_nav() {24 $bp_nav = buddypress()->bp_nav;25 26 $u = self::factory()->user->create();27 $old_current_user = get_current_user_id();28 $this->set_current_user( $u );29 $this->set_permalink_structure( '/%postname%/' );30 31 $this->go_to( bp_members_get_user_url( $u ) );32 33 bp_core_new_nav_item( array(34 'name' => 'Foo',35 'slug' => 'foo',36 'position' => 25,37 'screen_function' => 'foo_screen_function',38 'default_subnav_slug' => 'foo-sub'39 ) );40 41 $expected = array(42 'name' => 'Foo',43 'slug' => 'foo',44 'link' => bp_members_get_user_url(45 $u,46 array(47 'single_item_component' => 'foo',48 )49 ),50 'css_id' => 'foo',51 'show_for_displayed_user' => true,52 'position' => 25,53 'screen_function' => 'foo_screen_function',54 'default_subnav_slug' => 'foo-sub'55 );56 57 foreach ( $expected as $k => $v ) {58 $this->assertEquals( $v, buddypress()->bp_nav['foo'][ $k ] );59 }60 61 // Clean up62 buddypress()->bp_nav = $bp_nav;63 $this->set_current_user( $old_current_user );64 }65 66 /**67 * @expectedIncorrectUsage bp_nav68 */69 public function test_group_nav() {70 $bp_nav = buddypress()->bp_nav;71 72 $u = self::factory()->user->create();73 $g = self::factory()->group->create();74 $old_current_user = get_current_user_id();75 $this->set_current_user( $u );76 $this->set_permalink_structure( '/%postname%/' );77 78 $group = groups_get_group( $g );79 80 $this->go_to( bp_get_group_url( $group ) );81 82 $this->assertTrue( buddypress()->bp_nav[ $group->slug ]['position'] === -1 );83 84 // Clean up85 buddypress()->bp_nav = $bp_nav;86 $this->set_current_user( $old_current_user );87 18 } 88 19 … … 115 46 } 116 47 117 /**118 * @expectedIncorrectUsage bp_nav119 */120 public function test_css_id_should_fall_back_on_slug() {121 $args = array(122 'name' => 'Foo',123 'slug' => 'foo',124 );125 bp_core_new_nav_item( $args );126 127 $this->assertSame( 'foo', buddypress()->bp_nav['foo']['css_id'] );128 }129 130 /**131 * @expectedIncorrectUsage bp_nav132 */133 public function test_css_id_should_be_respected() {134 $args = array(135 'name' => 'Foo',136 'slug' => 'foo',137 'item_css_id' => 'bar',138 );139 bp_core_new_nav_item( $args );140 141 $this->assertSame( 'bar', buddypress()->bp_nav['foo']['css_id'] );142 }143 144 48 public function test_show_for_displayed_user_false_should_force_function_to_return_false_when_bp_user_has_access_is_also_false() { 145 49 $args = array( … … 155 59 $this->assertFalse( $retval ); 156 60 } 157 158 /**159 * @expectedIncorrectUsage bp_nav160 */161 public function test_existence_of_access_protected_user_nav() {162 $bp_nav = buddypress()->bp_nav;163 164 $u = self::factory()->user->create();165 $u2 = self::factory()->user->create();166 $old_current_user = get_current_user_id();167 $this->set_current_user( $u2 );168 $this->set_permalink_structure( '/%postname%/' );169 170 $this->go_to( bp_members_get_user_url( $u ) );171 172 $expected = array(173 'name' => 'Settings',174 'slug' => 'settings',175 'link' => bp_members_get_user_url(176 $u,177 array(178 'single_item_component' => 'settings',179 )180 ),181 'css_id' => 'settings',182 'show_for_displayed_user' => false,183 'position' => 100,184 'screen_function' => 'bp_settings_screen_general',185 'default_subnav_slug' => 'general'186 );187 188 foreach ( $expected as $k => $v ) {189 $this->assertEquals( $v, buddypress()->bp_nav['settings'][ $k ] );190 }191 192 // Clean up193 buddypress()->bp_nav = $bp_nav;194 $this->set_current_user( $old_current_user );195 }196 197 /**198 * @expectedIncorrectUsage bp_nav199 */200 public function test_creation_of_access_protected_user_nav() {201 // The nav item must be added to bp_nav, even if the current user202 // can't visit that nav item.203 $bp_nav = buddypress()->bp_nav;204 205 $u = self::factory()->user->create();206 $u2 = self::factory()->user->create();207 $old_current_user = get_current_user_id();208 $this->set_current_user( $u2 );209 $this->set_permalink_structure( '/%postname%/' );210 211 $this->go_to( bp_members_get_user_url( $u ) );212 213 bp_core_new_nav_item( array(214 'name' => 'Woof',215 'slug' => 'woof',216 'show_for_displayed_user' => false,217 'position' => 35,218 'screen_function' => 'woof_screen_function',219 'default_subnav_slug' => 'woof-one'220 ) );221 222 $expected = array(223 'name' => 'Woof',224 'slug' => 'woof',225 'link' => bp_members_get_user_url(226 $u,227 array(228 'single_item_component' => 'woof',229 )230 ),231 'css_id' => 'woof',232 'show_for_displayed_user' => false,233 'position' => 35,234 'screen_function' => 'woof_screen_function',235 'default_subnav_slug' => 'woof-one'236 );237 238 foreach ( $expected as $k => $v ) {239 $this->assertEquals( $v, buddypress()->bp_nav['woof'][ $k ] );240 }241 242 // Clean up243 buddypress()->bp_nav = $bp_nav;244 $this->set_current_user( $old_current_user );245 }246 61 }
Note: See TracChangeset
for help on using the changeset viewer.