| 882 | |
| 883 | /** |
| 884 | * @ticket 25750 |
| 885 | */ |
| 886 | function test_get_pages_hierarchical_and_no_parent() { |
| 887 | global $wpdb; |
| 888 | $page_1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); |
| 889 | $page_2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 890 | $page_3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_1 ) ); |
| 891 | $page_4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_2 ) ); |
| 892 | |
| 893 | $pages = get_pages(); // Defaults: hierarchical = true, parent = -1 |
| 894 | $pages_default_args = get_pages( array( 'hierarchical' => true, 'parent' => -1 ) ); |
| 895 | // Confirm the defaults. |
| 896 | $this->assertEquals( $pages, $pages_default_args ); |
| 897 | |
| 898 | /* |
| 899 | * Here's the tree we are testing: |
| 900 | * |
| 901 | * page 1 |
| 902 | * - page 2 |
| 903 | * -- page 4 |
| 904 | * - page 3 |
| 905 | * |
| 906 | * If hierarchical => true works, the order will be 1,2,4,3. |
| 907 | * If it doesn't, they will be in the creation order, 1,2,3,4. |
| 908 | */ |
| 909 | |
| 910 | $this->assertEqualSets( array( $page_1, $page_2, $page_4, $page_3 ), wp_list_pluck( $pages, 'ID' ) ); |
| 911 | } |