WordPress.org

Make WordPress Core

Ticket #39055: 39055_tests_current_behavior_refresh_take2.diff

File 39055_tests_current_behavior_refresh_take2.diff, 2.1 KB (added by fibonaccina, 3 years ago)

Correct test results

  • tests/phpunit/tests/query/results.php

     
    366366        }
    367367
    368368        /**
     369         * @ticket 39055
     370         */
     371        function test_query_orderby_post__in_with_no_order_specified() {
     372                $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );
     373                $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );
     374
     375                $q = new WP_Query( array(
     376                        'post__in' => $post__in_array,
     377                        'orderby'  => 'post__in',
     378                        'fields'   => 'ids'
     379                ) );
     380
     381                // Expect post ids in the same order as post__in array when no 'order' param is passed in
     382                $this->assertSame( $expected_returned_array, $q->posts );
     383        }
     384
     385        /**
     386         * @ticket 39055
     387         */
     388        function test_query_orderby_post__in_with_order_asc() {
     389                $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );
     390                $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );
     391
     392                $q = new WP_Query( array(
     393                        'post__in' => $post__in_array,
     394                        'orderby'  => 'post__in',
     395                        'order'    => 'asc',
     396                        'fields'   => 'ids'
     397                ) );
     398
     399                // Expect post ids in the same order as post__in array when order=asc is passed in
     400                $this->assertSame( $expected_returned_array, $q->posts );
     401         }
     402
     403        /**
     404         * @ticket 39055
     405         */
     406        function test_query_orderby_post__in_with_order_desc() {
     407                $post__in_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] );
     408                $expected_returned_array = array( self::$post_ids[1], self::$post_ids[2], self::$post_ids[0] );
     409
     410                $q = new WP_Query( array(
     411                        'post__in' => $post__in_array,
     412                        'orderby'  => 'post__in',
     413                        'order'    => 'desc',
     414                        'fields'   => 'ids'
     415                ) );
     416
     417                // Note that results are returned in the order specified in the post__in array
     418                // Order=desc does not have an effect on the order of returned results
     419                $this->assertSame( $expected_returned_array, $q->posts );
     420        }
     421
     422        /**
    369423         * @ticket 27252
    370424         * @ticket 31194
    371425         */