Make WordPress Core


Ignore:
Timestamp:
05/04/2016 06:56:58 PM (10 years ago)
Author:
boonebgorges
Message:

Users: The 'who' parameter should not interfere with 'meta_key' + 'meta_value' in WP_User_Query.

Props adrianosilvaferreira.
Fixes #36724.

File:
1 edited

Legend:

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

    r37359 r37360  
    694694                )
    695695            ),
     696        ) );
     697
     698        $found = wp_list_pluck( $q->get_results(), 'ID' );
     699
     700        $this->assertNotContains( self::$author_ids[0], $found );
     701        $this->assertContains( self::$author_ids[1], $found );
     702        $this->assertNotContains( self::$author_ids[2], $found );
     703    }
     704
     705    /**
     706     * @ticket 36724
     707     */
     708    public function test_who_authors_should_work_alongside_meta_params() {
     709        if ( ! is_multisite() ) {
     710            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     711        }
     712
     713        $b = self::factory()->blog->create();
     714
     715        add_user_to_blog( $b, self::$author_ids[0], 'subscriber' );
     716        add_user_to_blog( $b, self::$author_ids[1], 'author' );
     717        add_user_to_blog( $b, self::$author_ids[2], 'editor' );
     718
     719        add_user_meta( self::$author_ids[1], 'foo', 'bar' );
     720        add_user_meta( self::$author_ids[2], 'foo', 'baz' );
     721
     722        $q = new WP_User_Query( array(
     723            'who' => 'authors',
     724            'blog_id' => $b,
     725            'meta_key' => 'foo',
     726            'meta_value' => 'bar',
    696727        ) );
    697728
Note: See TracChangeset for help on using the changeset viewer.