Allow user_id to be an array of IDs in WP_Comment_Query.

props mordauk.
fixes #27064.


git-svn-id: https://develop.svn.wordpress.org/trunk@27258 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2014-02-25 16:34:25 +00:00
parent 19d7d1dd09
commit a407ae2363
2 changed files with 30 additions and 1 deletions

View File

@@ -156,4 +156,28 @@ class Tests_Comment_Query extends WP_UnitTestCase {
$this->assertEquals( 10, count( get_comments( array( 'status' => 'trash' ) ) ) );
$this->assertEquals( 10, count( get_comments( array( 'status' => 'spam' ) ) ) );
}
/**
* @ticket 27064
*/
function test_get_comments_by_user() {
$users = $this->factory->user->create_many( 2 );
$this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
$this->factory->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
$this->factory->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) );
$comments = get_comments( array( 'user_id' => $users[0] ) );
$this->assertCount( 2, $comments );
$this->assertEquals( $users[0], $comments[0]->user_id );
$this->assertEquals( $users[0], $comments[1]->user_id );
$comments = get_comments( array( 'user_id' => $users ) );
$this->assertCount( 3, $comments );
$this->assertEquals( $users[0], $comments[0]->user_id );
$this->assertEquals( $users[0], $comments[1]->user_id );
$this->assertEquals( $users[1], $comments[2]->user_id );
}
}