Make WordPress Core


Ignore:
Timestamp:
09/14/2015 10:38:02 PM (9 years ago)
Author:
wonderboymusic
Message:

Ensure that the count cache for all is in sync with comment-{$post_id} values. These are the values most often relied-upon by the list table for comments.

Adds unit tests.

See #33875.

File:
1 edited

Legend:

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

    r34131 r34136  
    107107        $this->assertEquals( 1, $count1->total_comments );
    108108
     109        $all_count1 = wp_count_comments();
     110
     111        $this->assertEquals( 1, $all_count1->approved );
     112        $this->assertEquals( 0, $all_count1->moderated );
     113        $this->assertEquals( 0, $all_count1->spam );
     114        $this->assertEquals( 0, $all_count1->trash );
     115        $this->assertEquals( 0, $all_count1->{'post-trashed'} );
     116        $this->assertEquals( 1, $all_count1->total_comments );
     117
    109118        wp_spam_comment( $comment_id );
     119
    110120        $count2 = wp_count_comments( $post_id );
    111121
     
    117127        $this->assertEquals( 1, $count2->total_comments );
    118128
     129        $all_count2 = wp_count_comments();
     130
     131        $this->assertEquals( 0, $all_count2->approved );
     132        $this->assertEquals( 0, $all_count2->moderated );
     133        $this->assertEquals( 1, $all_count2->spam );
     134        $this->assertEquals( 0, $all_count2->trash );
     135        $this->assertEquals( 0, $all_count2->{'post-trashed'} );
     136        $this->assertEquals( 1, $all_count2->total_comments );
     137
    119138        wp_trash_comment( $comment_id );
     139
    120140        $count3 = wp_count_comments( $post_id );
    121141
     
    126146        $this->assertEquals( 0, $count3->{'post-trashed'} );
    127147        $this->assertEquals( 0, $count3->total_comments );
    128        
     148
     149        $all_count3 = wp_count_comments();
     150
     151        $this->assertEquals( 0, $all_count3->approved );
     152        $this->assertEquals( 0, $all_count3->moderated );
     153        $this->assertEquals( 0, $all_count3->spam );
     154        $this->assertEquals( 1, $all_count3->trash );
     155        $this->assertEquals( 0, $all_count3->{'post-trashed'} );
     156        $this->assertEquals( 0, $all_count3->total_comments );
     157
    129158        wp_untrash_comment( $comment_id );
     159
    130160        $count4 = wp_count_comments( $post_id );
    131161
     
    136166        $this->assertEquals( 0, $count4->{'post-trashed'} );
    137167        $this->assertEquals( 1, $count4->total_comments );
     168
     169        $all_count4 = wp_count_comments();
     170
     171        $this->assertEquals( 0, $all_count4->approved );
     172        $this->assertEquals( 0, $all_count4->moderated );
     173        $this->assertEquals( 1, $all_count4->spam );
     174        $this->assertEquals( 0, $all_count4->trash );
     175        $this->assertEquals( 0, $all_count4->{'post-trashed'} );
     176        $this->assertEquals( 1, $all_count4->total_comments );
    138177    }
    139178}
Note: See TracChangeset for help on using the changeset viewer.