Make WordPress Core


Ignore:
Timestamp:
09/01/2016 04:50:47 PM (8 years ago)
Author:
boonebgorges
Message:

Query: 'orderby=include' should support comma-separated lists.

[30052] assumed that 'include' would be an array.

Props TimothyBlynJacobs.
Fixes #37904.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/query.php

    r38211 r38500  
    166166        $this->assertNotEmpty( $q2->terms );
    167167    }
     168
     169    /**
     170     * @ticket 23261
     171     * @ticket 37904
     172     */
     173    public function test_orderby_include_with_comma_separated_list() {
     174        register_taxonomy( 'wptests_tax_1', 'post' );
     175
     176        $t1 = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax_1' ) );
     177        $t2 = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax_1' ) );
     178
     179        $query = new WP_Term_Query( array(
     180            'include' => "{$t1->term_id},{$t2->term_id}",
     181            'orderby' => 'include',
     182            'hide_empty' => false,
     183        ) );
     184        $terms = $query->get_terms();
     185
     186        $this->assertEquals( array( $t1, $t2 ), $terms );
     187    }
    168188}
Note: See TracChangeset for help on using the changeset viewer.