mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 11:14:36 +00:00
Use WP_Comment_Query to query comments in get_approved_comments().
Props dancameron. See #12668. git-svn-id: https://develop.svn.wordpress.org/trunk@30098 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -14,4 +14,20 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
$result = wp_update_comment( array( 'comment_ID' => $comments[0], 'comment_parent' => $comments[1] ) );
|
||||
$this->assertEquals( 0, $result );
|
||||
}
|
||||
|
||||
public function test_get_approved_comments() {
|
||||
$p = $this->factory->post->create();
|
||||
$ca1 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1' ) );
|
||||
$ca2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1' ) );
|
||||
$ca3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '0' ) );
|
||||
$c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1', 'comment_type' => 'pingback' ) );
|
||||
$c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1', 'comment_type' => 'trackback' ) );
|
||||
$c4 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1', 'comment_type' => 'mario' ) );
|
||||
$c5 = $this->factory->comment->create( array( 'comment_post_ID' => $p, 'comment_approved' => '1', 'comment_type' => 'luigi' ) );
|
||||
|
||||
$found = get_approved_comments( $p );
|
||||
|
||||
// all comments types will be returned
|
||||
$this->assertEquals( array( $ca1, $ca2, $c2, $c3, $c4, $c5 ), wp_list_pluck( $found, 'comment_ID' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user