Changeset 34699
- Timestamp:
- 09/29/2015 09:27:03 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPages.php
r34698 r34699 275 275 } 276 276 277 /** 278 * @ticket 18701 279 */ 280 public function test_get_pages_hierarchical_non_empty_child_of() { 281 $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); 282 $page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) ); 283 $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); 284 $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); 285 $page_5 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); 286 287 $pages = get_pages( array( 'child_of' => $page_1 ) ); // Defaults: hierarchical = true, parent = -1. 288 289 /* 290 * Page tree: 291 * 292 * page 1 (parent 0) 293 * – page 3 (parent 1) 294 * –– page 4 (parent 3) 295 * – page 5 (parent 1) 296 * page 2 (parent 0) 297 * 298 * If hierarchical is true (default), and child_of is not empty, pages will be returned 299 * hierarchically in order of creation: 3, 4, 5. 300 */ 301 302 $this->assertEqualSets( array( $page_3, $page_4, $page_5 ), wp_list_pluck( $pages, 'ID' ) ); 303 } 304 305 /** 306 * @ticket 18701 307 */ 308 public function test_get_pages_non_hierarchical_non_empty_child_of() { 309 $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); 310 $page_2 = $this->factory->post->create( array( 'post_type' => 'page' ) ); 311 $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); 312 $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_3 ) ); 313 $page_5 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); 314 315 $pages = get_pages( array( 'hierarchical' => false, 'child_of' => $page_1 ) ); 316 317 /* 318 * Page tree: 319 * 320 * page 1 (parent 0) 321 * – page 3 (parent 1) 322 * –– page 4 (parent 3) 323 * – page 5 (parent 1) 324 * page 2 (parent 0) 325 * 326 * If hierarchical is false, and child_of is not empty, pages will (apparently) be returned 327 * hierarchically anyway in order of creation: 3, 4, 5. 328 */ 329 $this->assertEqualSets( array( $page_3, $page_4, $page_5 ), wp_list_pluck( $pages, 'ID' ) ); 330 331 // How it should work. 332 $found_pages = wp_list_filter( $pages, array( 'post_parent' => $page_1 ) ); 333 $this->assertEqualSets( array( $page_3, $page_5 ), wp_list_pluck( $found_pages, 'ID' ) ); 334 335 } 336 277 337 function test_wp_list_pages_classes() { 278 338 $type = 'taco';
Note: See TracChangeset
for help on using the changeset viewer.