mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Allow get_pages() to accept an array for the arg parent. Adds unit tests, some will fail until the next commit.
Fixes #9470. git-svn-id: https://develop.svn.wordpress.org/trunk@25244 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -823,4 +823,29 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
sort( $exc_result );
|
||||
$this->assertEquals( $inc, $exc_result );
|
||||
}
|
||||
|
||||
function test_get_pages_parent() {
|
||||
$page_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
$page_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
|
||||
$page_id3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) );
|
||||
$page_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );
|
||||
|
||||
$pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) );
|
||||
$this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) );
|
||||
|
||||
$pages = get_pages( array( 'parent' => $page_id1, 'hierarchical' => false ) );
|
||||
$this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );
|
||||
|
||||
$pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ), 'hierarchical' => false ) );
|
||||
$this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );
|
||||
|
||||
$pages = get_pages( array( 'parent' => 0 ) );
|
||||
$this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) );
|
||||
|
||||
$pages = get_pages( array( 'parent' => $page_id1 ) );
|
||||
$this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );
|
||||
|
||||
$pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ) ) );
|
||||
$this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user