| | 826 | |
| | 827 | /** |
| | 828 | * @ticket 9470 |
| | 829 | */ |
| | 830 | function test_get_pages_parent() { |
| | 831 | $page_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); |
| | 832 | $page_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); |
| | 833 | $page_id3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) ); |
| | 834 | $page_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); |
| | 835 | |
| | 836 | $pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) ); |
| | 837 | $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) ); |
| | 838 | |
| | 839 | $pages = get_pages( array( 'parent' => $page_id1, 'hierarchical' => false ) ); |
| | 840 | $this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); |
| | 841 | |
| | 842 | $pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ), 'hierarchical' => false ) ); |
| | 843 | $this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); |
| | 844 | |
| | 845 | $pages = get_pages( array( 'parent' => 0 ) ); |
| | 846 | $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) ); |
| | 847 | |
| | 848 | $pages = get_pages( array( 'parent' => $page_id1 ) ); |
| | 849 | $this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); |
| | 850 | |
| | 851 | $pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ) ) ); |
| | 852 | $this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); |
| | 853 | } |