Move test_get_pages_include_exclude() and test_get_pages_parent() to tests/post/getPages.php. Add a @ticket reference. see [25168] and [25244].
git-svn-id: https://develop.svn.wordpress.org/trunk@25972 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
eb01af41c2
commit
ddf0147a4f
@ -829,54 +829,4 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$counts->publish = 7;
|
||||
return $counts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22074
|
||||
*/
|
||||
function test_get_pages_include_exclude() {
|
||||
$page_ids = array();
|
||||
|
||||
foreach ( range( 1, 20 ) as $i )
|
||||
$page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
|
||||
$inc = array_slice( $page_ids, 0, 10 );
|
||||
sort( $inc );
|
||||
$exc = array_slice( $page_ids, 10 );
|
||||
sort( $exc );
|
||||
|
||||
$include = get_pages( array( 'include' => $inc ) );
|
||||
$inc_result = wp_list_pluck( $include, 'ID' );
|
||||
sort( $inc_result );
|
||||
$this->assertEquals( $inc, $inc_result );
|
||||
|
||||
$exclude = get_pages( array( 'exclude' => $exc ) );
|
||||
$exc_result = wp_list_pluck( $exclude, 'ID' );
|
||||
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' ) );
|
||||
}
|
||||
}
|
||||
|
@ -107,6 +107,59 @@ class Tests_Post_getPages extends WP_UnitTestCase {
|
||||
$this->assertEquals( 3, count( get_pages( array( 'meta_key' => 'some-meta-key' ) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22074
|
||||
*/
|
||||
function test_get_pages_include_exclude() {
|
||||
$page_ids = array();
|
||||
|
||||
foreach ( range( 1, 20 ) as $i )
|
||||
$page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
|
||||
$inc = array_slice( $page_ids, 0, 10 );
|
||||
sort( $inc );
|
||||
$exc = array_slice( $page_ids, 10 );
|
||||
sort( $exc );
|
||||
|
||||
$include = get_pages( array( 'include' => $inc ) );
|
||||
$inc_result = wp_list_pluck( $include, 'ID' );
|
||||
sort( $inc_result );
|
||||
$this->assertEquals( $inc, $inc_result );
|
||||
|
||||
$exclude = get_pages( array( 'exclude' => $exc ) );
|
||||
$exc_result = wp_list_pluck( $exclude, 'ID' );
|
||||
sort( $exc_result );
|
||||
$this->assertEquals( $inc, $exc_result );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 9470
|
||||
*/
|
||||
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' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 22389
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user