Make WordPress Core

Ticket #39055: 39055_additional_tests.diff

File 39055_additional_tests.diff, 2.2 KB (added by fibonaccina, 7 years ago)

Additional tests for 'post_namein' and 'post_parentin'

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

     
    368368        /**
    369369         * @ticket 39055
    370370         */
     371        function test_query_orderby_post_parent__in_with_order_desc() {
     372                $post_parent__in_array = array( self::$parent_two, self::$parent_one );
     373                $expected_returned_array = array( 'child-three', 'child-four', 'child-one', 'child-two' );
     374               
     375                $posts = $this->q->query( array(
     376                        'post_parent__in' => $post_parent__in_array,
     377                        'orderby'                               => 'post_parent__in',
     378                        'order'                                         => 'desc',
     379                ) );
     380
     381                // order=desc does not influence the order of returned results (returns same order as order=asc)
     382                $this->assertEquals( $expected_returned_array, wp_list_pluck( $posts, 'post_title' ) );
     383        }
     384
     385        /**
     386         * @ticket 39055
     387         */
    371388        function test_query_orderby_post__in_with_no_order_specified() {
    372389                $post__in_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );
    373390                $expected_returned_array = array( self::$post_ids[2], self::$post_ids[0], self::$post_ids[1] );
     
    420437        }
    421438
    422439        /**
     440         * @ticket 39055
     441         */
     442        function test_query_orderby_post_name__in_with_order_asc() {
     443                $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' );
     444
     445                $q = new WP_Query( array(
     446                        'post_name__in' => $post_name__in_array,
     447                        'orderby'                       => 'post_name__in',
     448                        'order'                         => 'asc'
     449                ) );
     450
     451                $this->assertSame( $post_name__in_array, array_unique( wp_list_pluck( $q->posts, 'post_title' ) ) );
     452        }
     453
     454        /**
     455         * @ticket 39055
     456         */
     457        function test_query_orderby_post_name__in_with_order_desc() {
     458                $post_name__in_array = array( 'parent-two', 'parent-one', 'parent-three' );
     459
     460                $q = new WP_Query( array(
     461                        'post_name__in' => $post_name__in_array,
     462                        'orderby'                       => 'post_name__in',
     463                        'order'                         => 'desc'
     464                ) );
     465
     466                // order=desc does not influence the order of returned results (returns same order as order=asc)
     467                $this->assertSame( $post_name__in_array, array_unique( wp_list_pluck( $q->posts, 'post_title' ) ) );
     468        }
     469
     470        /**
    423471         * @ticket 27252
    424472         * @ticket 31194
    425473         */