diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index 53a23f2669..bcff83916b 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -365,6 +365,23 @@ class Tests_Query_Results extends WP_UnitTestCase { ), wp_list_pluck( $posts, 'post_title' ) ); } + /** + * @ticket 39055 + */ + function test_query_orderby_post_parent__in_with_order_desc() { + $post_parent__in_array = array( self::$parent_two, self::$parent_one ); + $expected_returned_array = array( 'child-three', 'child-four', 'child-one', 'child-two' ); + + $posts = $this->q->query( array( + 'post_parent__in' => $post_parent__in_array, + 'orderby' => 'post_parent__in', + 'order' => 'desc', + ) ); + + // order=desc does not influence the order of returned results (returns same order as order=asc) + $this->assertEquals( $expected_returned_array, wp_list_pluck( $posts, 'post_title' ) ); + } + /** * @ticket 39055 */ @@ -419,6 +436,37 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $expected_returned_array, $q->posts ); } + /** + * @ticket 39055 + */ + function test_query_orderby_post_name__in_with_order_asc() { + $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' ); + + $q = new WP_Query( array( + 'post_name__in' => $post_name__in_array, + 'orderby' => 'post_name__in', + 'order' => 'asc' + ) ); + + $this->assertSame( $post_name__in_array, array_unique( wp_list_pluck( $q->posts, 'post_title' ) ) ); + } + + /** + * @ticket 39055 + */ + function test_query_orderby_post_name__in_with_order_desc() { + $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' ); + + $q = new WP_Query( array( + 'post_name__in' => $post_name__in_array, + 'orderby' => 'post_name__in', + 'order' => 'desc' + ) ); + + // order=desc does not influence the order of returned results (returns same order as order=asc) + $this->assertSame( $post_name__in_array, array_unique( wp_list_pluck( $q->posts, 'post_title' ) ) ); + } + /** * @ticket 27252 * @ticket 31194