WordPress.org

Make WordPress Core

Ticket #48093: 48093.diff

File 48093.diff, 8.3 KB (added by m.usama.masood, 6 weeks ago)
  • src/wp-includes/comment.php

     
    368368 * @return array() {
    369369 *     The number of comments keyed by their status.
    370370 *
    371  *     @type int|string $approved            The number of approved comments.
    372  *     @type int|string $awaiting_moderation The number of comments awaiting moderation (a.k.a. pending).
    373  *     @type int|string $spam                The number of spam comments.
    374  *     @type int|string $trash               The number of trashed comments.
    375  *     @type int|string $post-trashed        The number of comments for posts that are in the trash.
    376  *     @type int        $total_comments      The total number of non-trashed comments, including spam.
    377  *     @type int        $all                 The total number of pending or approved comments.
     371 *     @type int $approved            The number of approved comments.
     372 *     @type int $awaiting_moderation The number of comments awaiting moderation (a.k.a. pending).
     373 *     @type int $spam                The number of spam comments.
     374 *     @type int $trash               The number of trashed comments.
     375 *     @type int $post-trashed        The number of comments for posts that are in the trash.
     376 *     @type int $total_comments      The total number of non-trashed comments, including spam.
     377 *     @type int $all                 The total number of pending or approved comments.
    378378 * }
    379379 */
    380380function get_comment_count( $post_id = 0 ) {
     
    434434                }
    435435        }
    436436
    437         return $comment_count;
     437    return array_map('intval', $comment_count);
    438438}
    439439
    440440//
     
    13211321 * @return stdClass {
    13221322 *     The number of comments keyed by their status.
    13231323 *
    1324  *     @type int|string $approved       The number of approved comments.
    1325  *     @type int|string $moderated      The number of comments awaiting moderation (a.k.a. pending).
    1326  *     @type int|string $spam           The number of spam comments.
    1327  *     @type int|string $trash          The number of trashed comments.
    1328  *     @type int|string $post-trashed   The number of comments for posts that are in the trash.
    1329  *     @type int        $total_comments The total number of non-trashed comments, including spam.
    1330  *     @type int        $all            The total number of pending or approved comments.
     1324 *     @type int $approved       The number of approved comments.
     1325 *     @type int $moderated      The number of comments awaiting moderation (a.k.a. pending).
     1326 *     @type int $spam           The number of spam comments.
     1327 *     @type int $trash          The number of trashed comments.
     1328 *     @type int $post-trashed   The number of comments for posts that are in the trash.
     1329 *     @type int $total_comments The total number of non-trashed comments, including spam.
     1330 *     @type int $all            The total number of pending or approved comments.
    13311331 * }
    13321332 */
    13331333function wp_count_comments( $post_id = 0 ) {
  • tests/phpunit/tests/comment/getCommentCount.php

     
    55        public function test_get_comment_count() {
    66                $count = get_comment_count();
    77
    8                 $this->assertEquals( 0, $count['approved'] );
    9                 $this->assertEquals( 0, $count['awaiting_moderation'] );
    10                 $this->assertEquals( 0, $count['spam'] );
    11                 $this->assertEquals( 0, $count['trash'] );
    12                 $this->assertEquals( 0, $count['post-trashed'] );
    13                 $this->assertEquals( 0, $count['total_comments'] );
     8                $this->assertSame( 0, $count['approved'] );
     9                $this->assertSame( 0, $count['awaiting_moderation'] );
     10                $this->assertSame( 0, $count['spam'] );
     11                $this->assertSame( 0, $count['trash'] );
     12                $this->assertSame( 0, $count['post-trashed'] );
     13                $this->assertSame( 0, $count['total_comments'] );
    1414        }
    1515
    1616        public function test_get_comment_count_approved() {
     
    2222
    2323                $count = get_comment_count();
    2424
    25                 $this->assertEquals( 1, $count['approved'] );
    26                 $this->assertEquals( 0, $count['awaiting_moderation'] );
    27                 $this->assertEquals( 0, $count['spam'] );
    28                 $this->assertEquals( 0, $count['trash'] );
    29                 $this->assertEquals( 0, $count['post-trashed'] );
    30                 $this->assertEquals( 1, $count['total_comments'] );
     25                $this->assertSame( 1, $count['approved'] );
     26                $this->assertSame( 0, $count['awaiting_moderation'] );
     27                $this->assertSame( 0, $count['spam'] );
     28                $this->assertSame( 0, $count['trash'] );
     29                $this->assertSame( 0, $count['post-trashed'] );
     30                $this->assertSame( 1, $count['total_comments'] );
    3131        }
    3232
    3333        public function test_get_comment_count_awaiting() {
     
    3939
    4040                $count = get_comment_count();
    4141
    42                 $this->assertEquals( 0, $count['approved'] );
    43                 $this->assertEquals( 1, $count['awaiting_moderation'] );
    44                 $this->assertEquals( 0, $count['spam'] );
    45                 $this->assertEquals( 0, $count['trash'] );
    46                 $this->assertEquals( 0, $count['post-trashed'] );
    47                 $this->assertEquals( 1, $count['total_comments'] );
     42                $this->assertSame( 0, $count['approved'] );
     43                $this->assertSame( 1, $count['awaiting_moderation'] );
     44                $this->assertSame( 0, $count['spam'] );
     45                $this->assertSame( 0, $count['trash'] );
     46                $this->assertSame( 0, $count['post-trashed'] );
     47                $this->assertSame( 1, $count['total_comments'] );
    4848        }
    4949
    5050        public function test_get_comment_count_spam() {
     
    5656
    5757                $count = get_comment_count();
    5858
    59                 $this->assertEquals( 0, $count['approved'] );
    60                 $this->assertEquals( 0, $count['awaiting_moderation'] );
    61                 $this->assertEquals( 1, $count['spam'] );
    62                 $this->assertEquals( 0, $count['trash'] );
    63                 $this->assertEquals( 0, $count['post-trashed'] );
    64                 $this->assertEquals( 1, $count['total_comments'] );
     59                $this->assertSame( 0, $count['approved'] );
     60                $this->assertSame( 0, $count['awaiting_moderation'] );
     61                $this->assertSame( 1, $count['spam'] );
     62                $this->assertSame( 0, $count['trash'] );
     63                $this->assertSame( 0, $count['post-trashed'] );
     64                $this->assertSame( 1, $count['total_comments'] );
    6565        }
    6666
    6767        public function test_get_comment_count_trash() {
     
    7373
    7474                $count = get_comment_count();
    7575
    76                 $this->assertEquals( 0, $count['approved'] );
    77                 $this->assertEquals( 0, $count['awaiting_moderation'] );
    78                 $this->assertEquals( 0, $count['spam'] );
    79                 $this->assertEquals( 1, $count['trash'] );
    80                 $this->assertEquals( 0, $count['post-trashed'] );
    81                 $this->assertEquals( 0, $count['total_comments'] );
     76                $this->assertSame( 0, $count['approved'] );
     77                $this->assertSame( 0, $count['awaiting_moderation'] );
     78                $this->assertSame( 0, $count['spam'] );
     79                $this->assertSame( 1, $count['trash'] );
     80                $this->assertSame( 0, $count['post-trashed'] );
     81                $this->assertSame( 0, $count['total_comments'] );
    8282        }
    8383
    8484        public function test_get_comment_count_post_trashed() {
     
    9090
    9191                $count = get_comment_count();
    9292
    93                 $this->assertEquals( 0, $count['approved'] );
    94                 $this->assertEquals( 0, $count['awaiting_moderation'] );
    95                 $this->assertEquals( 0, $count['spam'] );
    96                 $this->assertEquals( 0, $count['trash'] );
    97                 $this->assertEquals( 1, $count['post-trashed'] );
    98                 $this->assertEquals( 0, $count['total_comments'] );
     93                $this->assertSame( 0, $count['approved'] );
     94                $this->assertSame( 0, $count['awaiting_moderation'] );
     95                $this->assertSame( 0, $count['spam'] );
     96                $this->assertSame( 0, $count['trash'] );
     97                $this->assertSame( 1, $count['post-trashed'] );
     98                $this->assertSame( 0, $count['total_comments'] );
    9999        }
    100100}
  • tests/phpunit/tests/import/import.php

     
    8181                $this->assertEquals( 4, $page_count->publish );
    8282                $this->assertEquals( 1, $page_count->draft );
    8383                $comment_count = wp_count_comments();
    84                 $this->assertEquals( 1, $comment_count->total_comments );
     84                $this->assertSame( 1, $comment_count->total_comments );
    8585
    8686                $posts = get_posts(
    8787                        array(
     
    245245                $this->assertEquals( 4, $page_count->publish );
    246246                $this->assertEquals( 1, $page_count->draft );
    247247                $comment_count = wp_count_comments();
    248                 $this->assertEquals( 1, $comment_count->total_comments );
     248                $this->assertSame( 1, $comment_count->total_comments );
    249249        }
    250250
    251251        function test_ordering_of_importers() {