- Timestamp:
- 05/12/2016 05:19:06 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/nav/bpCoreNewSubnavItem.php
r9991 r10745 6 6 class BP_Tests_Core_Nav_BpCoreNewSubnavItem extends BP_UnitTestCase { 7 7 8 /** 9 * @expectedIncorrectUsage bp_nav 10 */ 8 11 public function test_user_subnav() { 9 12 $bp_options_nav = buddypress()->bp_options_nav; … … 17 20 $this->go_to( $user_domain ); 18 21 22 bp_core_new_nav_item( array( 23 'name' => 'Foo Parent', 24 'slug' => 'foo-parent', 25 'link' => trailingslashit( $user_domain . 'foo-parent' ), 26 'screen_function' => 'foo_screen_function', 27 'position' => 10, 28 ) ); 29 19 30 bp_core_new_subnav_item( array( 20 31 'name' => 'Foo', 21 32 'slug' => 'foo', 22 'parent_url' => trailingslashit( $user_domain . 'foo ' ),23 'parent_slug' => 'foo ',33 'parent_url' => trailingslashit( $user_domain . 'foo-parent' ), 34 'parent_slug' => 'foo-parent', 24 35 'screen_function' => 'foo_screen_function', 25 36 'position' => 10 … … 28 39 $expected = array( 29 40 'name' => 'Foo', 30 'link' => trailingslashit( $user_domain . 'foo /foo' ),41 'link' => trailingslashit( $user_domain . 'foo-parent/foo' ), 31 42 'slug' => 'foo', 32 43 'css_id' => 'foo', … … 38 49 ); 39 50 40 $this->assertSame( buddypress()->bp_options_nav['foo']['foo'], $expected ); 51 foreach ( $expected as $k => $v ) { 52 $this->assertSame( $v, buddypress()->bp_options_nav['foo-parent']['foo'][ $k ] ); 53 } 41 54 42 55 // Clean up … … 103 116 } 104 117 118 /** 119 * @expectedIncorrectUsage bp_nav 120 */ 105 121 public function test_link_provided() { 106 122 $bp_options_nav = buddypress()->bp_options_nav; 107 123 108 bp_core_new_subnav_item( array( 109 'name' => 'bar', 110 'slug' => 'bar', 111 'parent_slug' => 'foo', 112 'parent_url' => 'foo', 124 bp_core_new_nav_item( array( 125 'name' => 'Foo', 126 'slug' => 'foo', 113 127 'screen_function' => 'foo', 114 128 'link' => 'https://buddypress.org/', 115 129 ) ); 116 130 131 bp_core_new_subnav_item( array( 132 'name' => 'bar', 133 'slug' => 'bar', 134 'parent_slug' => 'foo', 135 'parent_url' => 'foo', 136 'screen_function' => 'foo', 137 'link' => 'https://buddypress.org/', 138 ) ); 139 117 140 $this->assertSame( 'https://buddypress.org/', buddypress()->bp_options_nav['foo']['bar']['link'] ); 118 141 … … 120 143 } 121 144 145 /** 146 * @expectedIncorrectUsage bp_nav 147 */ 122 148 public function test_link_built_from_parent_url_and_slug() { 123 149 $bp_options_nav = buddypress()->bp_options_nav; 124 150 151 bp_core_new_nav_item( array( 152 'name' => 'Foo', 153 'slug' => 'foo', 154 'screen_function' => 'foo', 155 'link' => 'https://buddypress.org/', 156 ) ); 157 125 158 bp_core_new_subnav_item( array( 126 159 'name' => 'bar', … … 136 169 } 137 170 171 /** 172 * @expectedIncorrectUsage bp_nav 173 */ 138 174 public function test_link_built_from_parent_url_and_slug_where_slug_is_default() { 139 175 $bp_nav = buddypress()->bp_nav; 140 176 $bp_options_nav = buddypress()->bp_options_nav; 141 177 142 // fake the parent143 buddypress()->bp_nav = array(144 ' foo' => array(145 'default_subnav_slug' => 'bar',146 ),147 ) ;178 bp_core_new_nav_item( array( 179 'name' => 'Foo', 180 'slug' => 'foo', 181 'screen_function' => 'foo', 182 'default_subnav_slug' => 'bar', 183 ) ); 148 184 149 185 bp_core_new_subnav_item( array( … … 162 198 } 163 199 200 /** 201 * @expectedIncorrectUsage bp_nav 202 */ 164 203 public function test_should_trailingslash_link_when_link_is_autogenerated_using_slug() { 204 bp_core_new_nav_item( array( 205 'name' => 'Foo', 206 'slug' => 'foo', 207 'screen_function' => 'foo', 208 'link' => 'https://buddypress.org/', 209 ) ); 210 165 211 bp_core_new_subnav_item( array( 166 212 'name' => 'bar', … … 175 221 } 176 222 223 /** 224 * @expectedIncorrectUsage bp_nav 225 */ 177 226 public function test_should_trailingslash_link_when_link_is_autogenerated_not_using_slug() { 178 227 bp_core_new_nav_item( array( … … 188 237 'slug' => 'bar', 189 238 'parent_slug' => 'foo-parent', 190 'parent_url' => bp_get_root_domain() . ' foo-parent/',239 'parent_url' => bp_get_root_domain() . '/foo-parent/', 191 240 'screen_function' => 'bar', 192 241 ) ); 193 242 194 $expected = bp_get_root_domain() . ' foo-parent/';243 $expected = bp_get_root_domain() . '/foo-parent/'; 195 244 $this->assertSame( $expected, buddypress()->bp_options_nav['foo-parent']['bar']['link'] ); 196 245 } … … 198 247 /** 199 248 * @ticket BP6353 249 * @expectedIncorrectUsage bp_nav 200 250 */ 201 251 public function test_link_should_not_trailingslash_link_explicit_link() { 202 252 $link = 'http://example.com/foo/bar/blah/?action=edit&id=30'; 203 253 254 bp_core_new_nav_item( array( 255 'name' => 'Foo', 256 'slug' => 'foo', 257 'screen_function' => 'foo', 258 'link' => 'http://example.com/foo/', 259 ) ); 260 204 261 bp_core_new_subnav_item( array( 205 262 'name' => 'bar', … … 215 272 216 273 public function test_should_return_false_if_site_admin_only_and_current_user_cannot_bp_moderate() { 274 bp_core_new_nav_item( array( 275 'name' => 'Foo', 276 'slug' => 'foo', 277 'screen_function' => 'foo', 278 ) ); 279 217 280 // Should already be set to a 0 user. 218 281 $this->assertFalse( bp_current_user_can( 'bp_moderate' ) ); … … 229 292 } 230 293 294 /** 295 * @expectedIncorrectUsage bp_nav 296 */ 231 297 public function test_css_id_should_fall_back_on_slug() { 298 bp_core_new_nav_item( array( 299 'name' => 'Parent', 300 'slug' => 'parent', 301 'screen_function' => 'foo', 302 ) ); 303 232 304 $args = array( 233 305 'name' => 'Foo', … … 242 314 } 243 315 316 /** 317 * @expectedIncorrectUsage bp_nav 318 */ 244 319 public function test_css_id_should_be_respected() { 320 bp_core_new_nav_item( array( 321 'name' => 'Parent', 322 'slug' => 'parent', 323 'screen_function' => 'foo', 324 ) ); 325 245 326 $args = array( 246 327 'name' => 'Foo',
Note: See TracChangeset
for help on using the changeset viewer.