Make WordPress Core


Ignore:
Timestamp:
02/25/2014 04:34:25 PM (13 years ago)
Author:
nacin
Message:

Allow user_id to be an array of IDs in WP_Comment_Query.

props mordauk.
fixes #27064.

File:
1 edited

Legend:

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

    r25364 r27258  
    157157                $this->assertEquals( 10, count( get_comments( array( 'status' => 'spam' ) ) ) );
    158158        }
     159
     160        /**
     161         * @ticket 27064
     162         */
     163        function test_get_comments_by_user() {
     164                $users = $this->factory->user->create_many( 2 );
     165                $this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     166                $this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     167                $this->factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
     168
     169                $comments = get_comments( array( 'user_id' => $users[0] ) );
     170
     171                $this->assertCount( 2, $comments );
     172                $this->assertEquals( $users[0], $comments[0]->user_id );
     173                $this->assertEquals( $users[0], $comments[1]->user_id );
     174
     175                $comments = get_comments( array( 'user_id' => $users ) );
     176
     177                $this->assertCount( 3, $comments );
     178                $this->assertEquals( $users[0], $comments[0]->user_id );
     179                $this->assertEquals( $users[0], $comments[1]->user_id );
     180                $this->assertEquals( $users[1], $comments[2]->user_id );
     181
     182        }
    159183}
Note: See TracChangeset for help on using the changeset viewer.