Make WordPress Core

Ticket #36515: test-query.diff

File test-query.diff, 1.3 KB (added by postpostmodern, 9 years ago)

Patch for tests/phpunit/tests/post/query.php

  • tests/phpunit/tests/post/query.php

     
    178178                $this->assertEqualSets( $ordered, wp_list_pluck( $attached->posts, 'ID' ) );
    179179        }
    180180
     181        function test_post_name__in_ordering() {
     182                $post_id1 = self::factory()->post->create( array( 'post_name' => 'id-1', 'post_type' => 'page' ) );
     183                $post_id2 = self::factory()->post->create( array( 'post_name' => 'id-2', 'post_type' => 'page' ) );
     184                $post_id3 = self::factory()->post->create( array(
     185                        'post_name' => 'id-3',
     186                        'post_type' => 'page',
     187                        'post_parent' => $post_id2
     188                ) );
     189                $post_id4 = self::factory()->post->create( array(
     190                        'post_name' => 'id-4',
     191                        'post_type' => 'page',
     192                        'post_parent' => $post_id2
     193                ) );
     194                $post_id5 = self::factory()->post->create( array( 'post_name' => 'id-5', 'post_type' => 'page' ) );
     195
     196                $ordered = array( 'id-2', 'id-4', 'id-3', 'id-1', 'id-5' );
     197
     198                $q = new WP_Query( array(
     199                        'post_type' => 'any',
     200                        'post_name__in' => $ordered,
     201                        'orderby' => 'post_name__in'
     202                ) );
     203               
     204                $this->assertEquals( $ordered, wp_list_pluck( $q->posts, 'post_name' ) );
     205        }
     206
    181207        function test_post_status() {
    182208                $statuses1 = get_post_stati();
    183209                $this->assertContains( 'auto-draft', $statuses1 );