WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/31/2015 06:50:12 PM (6 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/getCommentCount.php

    r33806 r33822  
    99        $this->assertEquals( 0, $count['awaiting_moderation'] );
    1010        $this->assertEquals( 0, $count['spam'] );
     11        $this->assertEquals( 0, $count['trash'] );
     12        $this->assertEquals( 0, $count['post-trashed'] );
    1113        $this->assertEquals( 0, $count['total_comments'] );
    1214    }
     
    2224        $this->assertEquals( 0, $count['awaiting_moderation'] );
    2325        $this->assertEquals( 0, $count['spam'] );
     26        $this->assertEquals( 0, $count['trash'] );
     27        $this->assertEquals( 0, $count['post-trashed'] );
    2428        $this->assertEquals( 1, $count['total_comments'] );
    2529    }
     
    3539        $this->assertEquals( 1, $count['awaiting_moderation'] );
    3640        $this->assertEquals( 0, $count['spam'] );
     41        $this->assertEquals( 0, $count['trash'] );
     42        $this->assertEquals( 0, $count['post-trashed'] );
    3743        $this->assertEquals( 1, $count['total_comments'] );
    3844    }
     
    4854        $this->assertEquals( 0, $count['awaiting_moderation'] );
    4955        $this->assertEquals( 1, $count['spam'] );
     56        $this->assertEquals( 0, $count['trash'] );
     57        $this->assertEquals( 0, $count['post-trashed'] );
    5058        $this->assertEquals( 1, $count['total_comments'] );
    5159    }
     
    6169        $this->assertEquals( 0, $count['awaiting_moderation'] );
    6270        $this->assertEquals( 0, $count['spam'] );
     71        $this->assertEquals( 1, $count['trash'] );
     72        $this->assertEquals( 0, $count['post-trashed'] );
     73        $this->assertEquals( 0, $count['total_comments'] );
     74    }
     75
     76    public function test_get_comment_count_post_trashed() {
     77        $this->factory->comment->create( array(
     78            'comment_approved' => 'post-trashed'
     79        ) );
     80
     81        $count = get_comment_count();
     82
     83        $this->assertEquals( 0, $count['approved'] );
     84        $this->assertEquals( 0, $count['awaiting_moderation'] );
     85        $this->assertEquals( 0, $count['spam'] );
     86        $this->assertEquals( 0, $count['trash'] );
     87        $this->assertEquals( 1, $count['post-trashed'] );
    6388        $this->assertEquals( 0, $count['total_comments'] );
    6489    }
Note: See TracChangeset for help on using the changeset viewer.