From ddf0147a4f31392b9418ee02393be63246ec7a7f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 28 Oct 2013 21:49:27 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/post.php | 50 ------------------------- tests/phpunit/tests/post/getPages.php | 53 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index d259329997..6e6e4094d6 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -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' ) ); - } } diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index 8b660252e1..588490fb50 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -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 */