Changeset 9818
- Timestamp:
- 04/29/2015 05:19:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/nav.php
r9701 r9818 6 6 */ 7 7 class BP_Tests_Core_Nav extends BP_UnitTestCase { 8 9 /** 10 * @group bp_core_new_nav_item 11 */ 12 public function test_bp_core_new_nav_item_user_nav() { 13 $bp_nav = buddypress()->bp_nav; 14 15 $u = $this->factory->user->create(); 16 $old_current_user = get_current_user_id(); 17 $this->set_current_user( $u ); 18 19 $this->go_to( bp_core_get_user_domain( $u ) ); 20 21 bp_core_new_nav_item( array( 22 'name' => 'Foo', 23 'slug' => 'foo', 24 'position' => 25, 25 'screen_function' => 'foo_screen_function', 26 'default_subnav_slug' => 'foo-sub' 27 ) ); 28 29 $expected = array( 30 'name' => 'Foo', 31 'slug' => 'foo', 32 'link' => trailingslashit( bp_core_get_user_domain( $u ) . 'foo' ), 33 'css_id' => 'foo', 34 'show_for_displayed_user' => true, 35 'position' => 25, 36 'screen_function' => 'foo_screen_function', 37 'default_subnav_slug' => 'foo-sub' 38 ); 39 40 $this->assertSame( buddypress()->bp_nav['foo'], $expected ); 41 42 // Clean up 43 buddypress()->bp_nav = $bp_nav; 44 $this->set_current_user( $old_current_user ); 45 } 46 47 /** 48 * @group bp_core_new_nav_item 49 */ 50 public function test_bp_core_new_nav_item_group_nav() { 51 $bp_nav = buddypress()->bp_nav; 52 53 $u = $this->factory->user->create(); 54 $g = $this->factory->group->create(); 55 $old_current_user = get_current_user_id(); 56 $this->set_current_user( $u ); 57 58 $group = groups_get_group( array( 59 'group_id' => $g, 60 ) ); 61 62 $this->go_to( bp_get_group_permalink( $group ) ); 63 64 $this->assertTrue( buddypress()->bp_nav[ $group->slug ]['position'] === -1 ); 65 66 // Clean up 67 buddypress()->bp_nav = $bp_nav; 68 $this->set_current_user( $old_current_user ); 69 } 70 71 /** 72 * @group bp_core_sort_nav_items 73 */ 74 public function test_bp_core_sort_nav_items() { 75 $bp_nav = buddypress()->bp_nav; 76 77 $u = $this->factory->user->create(); 78 $old_current_user = get_current_user_id(); 79 $this->set_current_user( $u ); 80 81 $this->go_to( bp_core_get_user_domain( $u ) ); 82 83 bp_core_new_nav_item( array( 84 'name' => 'Foo', 85 'slug' => 'foo', 86 'position' => 25, 87 'screen_function' => 'foo_screen_function', 88 'default_subnav_slug' => 'foo-sub' 89 ) ); 90 91 $expected = array( 92 'name' => 'Foo', 93 'slug' => 'foo', 94 'link' => trailingslashit( bp_core_get_user_domain( $u ) . 'foo' ), 95 'css_id' => 'foo', 96 'show_for_displayed_user' => true, 97 'position' => 25, 98 'screen_function' => 'foo_screen_function', 99 'default_subnav_slug' => 'foo-sub' 100 ); 101 102 bp_core_sort_nav_items(); 103 104 $this->assertSame( buddypress()->bp_nav[25], $expected ); 105 106 // Clean up 107 buddypress()->bp_nav = $bp_nav; 108 $this->set_current_user( $old_current_user ); 109 } 110 111 /** 112 * @group bp_core_new_subnav_item 113 */ 114 public function test_bp_core_new_subnav_item_user_subnav() { 115 $bp_options_nav = buddypress()->bp_options_nav; 116 117 $u = $this->factory->user->create(); 118 $old_current_user = get_current_user_id(); 119 $this->set_current_user( $u ); 120 121 $user_domain = bp_core_get_user_domain( $u ); 122 123 $this->go_to( $user_domain ); 124 125 bp_core_new_subnav_item( array( 126 'name' => 'Foo', 127 'slug' => 'foo', 128 'parent_url' => trailingslashit( $user_domain . 'foo' ), 129 'parent_slug' => 'foo', 130 'screen_function' => 'foo_screen_function', 131 'position' => 10 132 ) ); 133 134 $expected = array( 135 'name' => 'Foo', 136 'link' => trailingslashit( $user_domain . 'foo/foo' ), 137 'slug' => 'foo', 138 'css_id' => 'foo', 139 'position' => 10, 140 'user_has_access' => true, 141 'no_access_url' => '', 142 'screen_function' => 'foo_screen_function', 143 'show_in_admin_bar' => false, 144 ); 145 146 $this->assertSame( buddypress()->bp_options_nav['foo']['foo'], $expected ); 147 148 // Clean up 149 buddypress()->bp_options_nav = $bp_options_nav; 150 $this->set_current_user( $old_current_user ); 151 } 152 8 153 /** 9 154 * @group bp_core_new_subnav_item … … 401 546 $this->assertSame( $link, buddypress()->bp_options_nav['foo']['bar']['link'] ); 402 547 } 548 549 /** 550 * @group bp_core_sort_subnav_items 551 */ 552 public function test_bp_core_sort_subnav_items() { 553 $bp_options_nav = buddypress()->bp_options_nav; 554 555 $u = $this->factory->user->create(); 556 $old_current_user = get_current_user_id(); 557 $this->set_current_user( $u ); 558 559 $user_domain = bp_core_get_user_domain( $u ); 560 561 $this->go_to( $user_domain ); 562 563 bp_core_new_subnav_item( array( 564 'name' => 'Foo', 565 'slug' => 'foo', 566 'parent_url' => trailingslashit( $user_domain . 'foo' ), 567 'parent_slug' => 'foo', 568 'screen_function' => 'foo_screen_function', 569 'position' => 10 570 ) ); 571 572 bp_core_sort_subnav_items(); 573 574 $expected = array( 575 'name' => 'Foo', 576 'link' => trailingslashit( $user_domain . 'foo/foo' ), 577 'slug' => 'foo', 578 'css_id' => 'foo', 579 'position' => 10, 580 'user_has_access' => true, 581 'no_access_url' => '', 582 'screen_function' => 'foo_screen_function', 583 'show_in_admin_bar' => false, 584 ); 585 586 $this->assertSame( buddypress()->bp_options_nav['foo'][10], $expected ); 587 588 // Clean up 589 buddypress()->bp_options_nav = $bp_options_nav; 590 $this->set_current_user( $old_current_user ); 591 } 403 592 }
Note: See TracChangeset
for help on using the changeset viewer.