mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Previously elements would be a mixture of strings and integers depending on their numeric value. Props progremzion, m.usama.masood Fixes #48093 git-svn-id: https://develop.svn.wordpress.org/trunk@47526 602fd350-edb4-49c9-b593-d223f7449a82
101 lines
2.7 KiB
PHP
101 lines
2.7 KiB
PHP
<?php
|
|
|
|
class Tests_Get_Comment_Count extends WP_UnitTestCase {
|
|
|
|
public function test_get_comment_count() {
|
|
$count = get_comment_count();
|
|
|
|
$this->assertSame( 0, $count['approved'] );
|
|
$this->assertSame( 0, $count['awaiting_moderation'] );
|
|
$this->assertSame( 0, $count['spam'] );
|
|
$this->assertSame( 0, $count['trash'] );
|
|
$this->assertSame( 0, $count['post-trashed'] );
|
|
$this->assertSame( 0, $count['total_comments'] );
|
|
}
|
|
|
|
public function test_get_comment_count_approved() {
|
|
self::factory()->comment->create(
|
|
array(
|
|
'comment_approved' => 1,
|
|
)
|
|
);
|
|
|
|
$count = get_comment_count();
|
|
|
|
$this->assertSame( 1, $count['approved'] );
|
|
$this->assertSame( 0, $count['awaiting_moderation'] );
|
|
$this->assertSame( 0, $count['spam'] );
|
|
$this->assertSame( 0, $count['trash'] );
|
|
$this->assertSame( 0, $count['post-trashed'] );
|
|
$this->assertSame( 1, $count['total_comments'] );
|
|
}
|
|
|
|
public function test_get_comment_count_awaiting() {
|
|
self::factory()->comment->create(
|
|
array(
|
|
'comment_approved' => 0,
|
|
)
|
|
);
|
|
|
|
$count = get_comment_count();
|
|
|
|
$this->assertSame( 0, $count['approved'] );
|
|
$this->assertSame( 1, $count['awaiting_moderation'] );
|
|
$this->assertSame( 0, $count['spam'] );
|
|
$this->assertSame( 0, $count['trash'] );
|
|
$this->assertSame( 0, $count['post-trashed'] );
|
|
$this->assertSame( 1, $count['total_comments'] );
|
|
}
|
|
|
|
public function test_get_comment_count_spam() {
|
|
self::factory()->comment->create(
|
|
array(
|
|
'comment_approved' => 'spam',
|
|
)
|
|
);
|
|
|
|
$count = get_comment_count();
|
|
|
|
$this->assertSame( 0, $count['approved'] );
|
|
$this->assertSame( 0, $count['awaiting_moderation'] );
|
|
$this->assertSame( 1, $count['spam'] );
|
|
$this->assertSame( 0, $count['trash'] );
|
|
$this->assertSame( 0, $count['post-trashed'] );
|
|
$this->assertSame( 1, $count['total_comments'] );
|
|
}
|
|
|
|
public function test_get_comment_count_trash() {
|
|
self::factory()->comment->create(
|
|
array(
|
|
'comment_approved' => 'trash',
|
|
)
|
|
);
|
|
|
|
$count = get_comment_count();
|
|
|
|
$this->assertSame( 0, $count['approved'] );
|
|
$this->assertSame( 0, $count['awaiting_moderation'] );
|
|
$this->assertSame( 0, $count['spam'] );
|
|
$this->assertSame( 1, $count['trash'] );
|
|
$this->assertSame( 0, $count['post-trashed'] );
|
|
$this->assertSame( 0, $count['total_comments'] );
|
|
}
|
|
|
|
public function test_get_comment_count_post_trashed() {
|
|
self::factory()->comment->create(
|
|
array(
|
|
'comment_approved' => 'post-trashed',
|
|
)
|
|
);
|
|
|
|
$count = get_comment_count();
|
|
|
|
$this->assertSame( 0, $count['approved'] );
|
|
$this->assertSame( 0, $count['awaiting_moderation'] );
|
|
$this->assertSame( 0, $count['spam'] );
|
|
$this->assertSame( 0, $count['trash'] );
|
|
$this->assertSame( 1, $count['post-trashed'] );
|
|
$this->assertSame( 0, $count['total_comments'] );
|
|
}
|
|
}
|