mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
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:
@@ -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 );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user