mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Comments: wp_count_comments() can use get_comment_count() internally to makes its DB query, provided that get_comment_count() returns more properties.
Adds/updates unit tests. There were zero (0) unit tests for `wp_count_comments()`. Fixes #19903. git-svn-id: https://develop.svn.wordpress.org/trunk@33822 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -8,6 +8,8 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
|
||||
$this->assertEquals( 0, $count['approved'] );
|
||||
$this->assertEquals( 0, $count['awaiting_moderation'] );
|
||||
$this->assertEquals( 0, $count['spam'] );
|
||||
$this->assertEquals( 0, $count['trash'] );
|
||||
$this->assertEquals( 0, $count['post-trashed'] );
|
||||
$this->assertEquals( 0, $count['total_comments'] );
|
||||
}
|
||||
|
||||
@@ -21,6 +23,8 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
|
||||
$this->assertEquals( 1, $count['approved'] );
|
||||
$this->assertEquals( 0, $count['awaiting_moderation'] );
|
||||
$this->assertEquals( 0, $count['spam'] );
|
||||
$this->assertEquals( 0, $count['trash'] );
|
||||
$this->assertEquals( 0, $count['post-trashed'] );
|
||||
$this->assertEquals( 1, $count['total_comments'] );
|
||||
}
|
||||
|
||||
@@ -34,6 +38,8 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
|
||||
$this->assertEquals( 0, $count['approved'] );
|
||||
$this->assertEquals( 1, $count['awaiting_moderation'] );
|
||||
$this->assertEquals( 0, $count['spam'] );
|
||||
$this->assertEquals( 0, $count['trash'] );
|
||||
$this->assertEquals( 0, $count['post-trashed'] );
|
||||
$this->assertEquals( 1, $count['total_comments'] );
|
||||
}
|
||||
|
||||
@@ -47,6 +53,8 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
|
||||
$this->assertEquals( 0, $count['approved'] );
|
||||
$this->assertEquals( 0, $count['awaiting_moderation'] );
|
||||
$this->assertEquals( 1, $count['spam'] );
|
||||
$this->assertEquals( 0, $count['trash'] );
|
||||
$this->assertEquals( 0, $count['post-trashed'] );
|
||||
$this->assertEquals( 1, $count['total_comments'] );
|
||||
}
|
||||
|
||||
@@ -60,6 +68,23 @@ class Tests_Get_Comment_Count extends WP_UnitTestCase {
|
||||
$this->assertEquals( 0, $count['approved'] );
|
||||
$this->assertEquals( 0, $count['awaiting_moderation'] );
|
||||
$this->assertEquals( 0, $count['spam'] );
|
||||
$this->assertEquals( 1, $count['trash'] );
|
||||
$this->assertEquals( 0, $count['post-trashed'] );
|
||||
$this->assertEquals( 0, $count['total_comments'] );
|
||||
}
|
||||
|
||||
public function test_get_comment_count_post_trashed() {
|
||||
$this->factory->comment->create( array(
|
||||
'comment_approved' => 'post-trashed'
|
||||
) );
|
||||
|
||||
$count = get_comment_count();
|
||||
|
||||
$this->assertEquals( 0, $count['approved'] );
|
||||
$this->assertEquals( 0, $count['awaiting_moderation'] );
|
||||
$this->assertEquals( 0, $count['spam'] );
|
||||
$this->assertEquals( 0, $count['trash'] );
|
||||
$this->assertEquals( 1, $count['post-trashed'] );
|
||||
$this->assertEquals( 0, $count['total_comments'] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user