Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r36275 r42343  
    1212     */
    1313    public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest() {
    14         $now = time();
    15         $p = self::factory()->post->create();
    16         $comment_1 = self::factory()->comment->create( array(
    17             'comment_post_ID' => $p,
    18             'comment_content' => '1',
    19             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    20         ) );
    21         $comment_2 = self::factory()->comment->create( array(
    22             'comment_post_ID' => $p,
    23             'comment_content' => '2',
    24             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    25         ) );
     14        $now       = time();
     15        $p         = self::factory()->post->create();
     16        $comment_1 = self::factory()->comment->create(
     17            array(
     18                'comment_post_ID'  => $p,
     19                'comment_content'  => '1',
     20                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     21            )
     22        );
     23        $comment_2 = self::factory()->comment->create(
     24            array(
     25                'comment_post_ID'  => $p,
     26                'comment_content'  => '2',
     27                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     28            )
     29        );
    2630
    2731        update_option( 'comment_order', 'asc' );
     
    4246     */
    4347    public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest() {
    44         $now = time();
    45         $p = self::factory()->post->create();
    46         $comment_1 = self::factory()->comment->create( array(
    47             'comment_post_ID' => $p,
    48             'comment_content' => '1',
    49             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    50         ) );
    51         $comment_2 = self::factory()->comment->create( array(
    52             'comment_post_ID' => $p,
    53             'comment_content' => '2',
    54             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    55         ) );
     48        $now       = time();
     49        $p         = self::factory()->post->create();
     50        $comment_1 = self::factory()->comment->create(
     51            array(
     52                'comment_post_ID'  => $p,
     53                'comment_content'  => '1',
     54                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     55            )
     56        );
     57        $comment_2 = self::factory()->comment->create(
     58            array(
     59                'comment_post_ID'  => $p,
     60                'comment_content'  => '2',
     61                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     62            )
     63        );
    5664
    5765        update_option( 'comment_order', 'desc' );
     
    7280     */
    7381    public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() {
    74         $now = time();
    75         $p = self::factory()->post->create();
    76         $comment_1 = self::factory()->comment->create( array(
    77             'comment_post_ID' => $p,
    78             'comment_content' => '1',
    79             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    80         ) );
    81         $comment_2 = self::factory()->comment->create( array(
    82             'comment_post_ID' => $p,
    83             'comment_content' => '2',
    84             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    85         ) );
     82        $now       = time();
     83        $p         = self::factory()->post->create();
     84        $comment_1 = self::factory()->comment->create(
     85            array(
     86                'comment_post_ID'  => $p,
     87                'comment_content'  => '1',
     88                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     89            )
     90        );
     91        $comment_2 = self::factory()->comment->create(
     92            array(
     93                'comment_post_ID'  => $p,
     94                'comment_content'  => '2',
     95                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     96            )
     97        );
    8698
    8799        update_option( 'comment_order', 'asc' );
     
    102114     */
    103115    public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() {
    104         $now = time();
    105         $p = self::factory()->post->create();
    106         $comment_1 = self::factory()->comment->create( array(
    107             'comment_post_ID' => $p,
    108             'comment_content' => '1',
    109             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    110         ) );
    111         $comment_2 = self::factory()->comment->create( array(
    112             'comment_post_ID' => $p,
    113             'comment_content' => '2',
    114             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    115         ) );
     116        $now       = time();
     117        $p         = self::factory()->post->create();
     118        $comment_1 = self::factory()->comment->create(
     119            array(
     120                'comment_post_ID'  => $p,
     121                'comment_content'  => '1',
     122                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     123            )
     124        );
     125        $comment_2 = self::factory()->comment->create(
     126            array(
     127                'comment_post_ID'  => $p,
     128                'comment_content'  => '2',
     129                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     130            )
     131        );
    116132
    117133        update_option( 'comment_order', 'desc' );
     
    132148     */
    133149    public function test_should_respect_comment_order_asc_when_default_comments_page_is_newest_on_subsequent_pages() {
    134         $now = time();
    135         $p = self::factory()->post->create();
    136         $comment_1 = self::factory()->comment->create( array(
    137             'comment_post_ID' => $p,
    138             'comment_content' => '1',
    139             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    140         ) );
    141         $comment_2 = self::factory()->comment->create( array(
    142             'comment_post_ID' => $p,
    143             'comment_content' => '2',
    144             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    145         ) );
    146         $comment_3 = self::factory()->comment->create( array(
    147             'comment_post_ID' => $p,
    148             'comment_content' => '3',
    149             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    150         ) );
    151         $comment_4 = self::factory()->comment->create( array(
    152             'comment_post_ID' => $p,
    153             'comment_content' => '4',
    154             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    155         ) );
    156         $comment_5 = self::factory()->comment->create( array(
    157             'comment_post_ID' => $p,
    158             'comment_content' => '3',
    159             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    160         ) );
    161         $comment_6 = self::factory()->comment->create( array(
    162             'comment_post_ID' => $p,
    163             'comment_content' => '4',
    164             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
    165         ) );
     150        $now       = time();
     151        $p         = self::factory()->post->create();
     152        $comment_1 = self::factory()->comment->create(
     153            array(
     154                'comment_post_ID'  => $p,
     155                'comment_content'  => '1',
     156                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     157            )
     158        );
     159        $comment_2 = self::factory()->comment->create(
     160            array(
     161                'comment_post_ID'  => $p,
     162                'comment_content'  => '2',
     163                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     164            )
     165        );
     166        $comment_3 = self::factory()->comment->create(
     167            array(
     168                'comment_post_ID'  => $p,
     169                'comment_content'  => '3',
     170                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     171            )
     172        );
     173        $comment_4 = self::factory()->comment->create(
     174            array(
     175                'comment_post_ID'  => $p,
     176                'comment_content'  => '4',
     177                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     178            )
     179        );
     180        $comment_5 = self::factory()->comment->create(
     181            array(
     182                'comment_post_ID'  => $p,
     183                'comment_content'  => '3',
     184                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
     185            )
     186        );
     187        $comment_6 = self::factory()->comment->create(
     188            array(
     189                'comment_post_ID'  => $p,
     190                'comment_content'  => '4',
     191                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
     192            )
     193        );
    166194
    167195        update_option( 'comment_order', 'asc' );
     
    169197        update_option( 'page_comments', '1' );
    170198
    171         $link = add_query_arg( array(
    172             'cpage' => 2,
    173             'comments_per_page' => 2,
    174         ), get_permalink( $p ) );
     199        $link = add_query_arg(
     200            array(
     201                'cpage'             => 2,
     202                'comments_per_page' => 2,
     203            ), get_permalink( $p )
     204        );
    175205
    176206        $this->go_to( $link );
     
    188218     */
    189219    public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() {
    190         $now = time();
    191         $p = self::factory()->post->create();
    192         $comment_1 = self::factory()->comment->create( array(
    193             'comment_post_ID' => $p,
    194             'comment_content' => '1',
    195             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    196         ) );
    197         $comment_2 = self::factory()->comment->create( array(
    198             'comment_post_ID' => $p,
    199             'comment_content' => '2',
    200             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    201         ) );
    202         $comment_3 = self::factory()->comment->create( array(
    203             'comment_post_ID' => $p,
    204             'comment_content' => '3',
    205             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    206         ) );
    207         $comment_4 = self::factory()->comment->create( array(
    208             'comment_post_ID' => $p,
    209             'comment_content' => '4',
    210             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    211         ) );
    212         $comment_5 = self::factory()->comment->create( array(
    213             'comment_post_ID' => $p,
    214             'comment_content' => '3',
    215             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    216         ) );
    217         $comment_6 = self::factory()->comment->create( array(
    218             'comment_post_ID' => $p,
    219             'comment_content' => '4',
    220             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
    221         ) );
     220        $now       = time();
     221        $p         = self::factory()->post->create();
     222        $comment_1 = self::factory()->comment->create(
     223            array(
     224                'comment_post_ID'  => $p,
     225                'comment_content'  => '1',
     226                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     227            )
     228        );
     229        $comment_2 = self::factory()->comment->create(
     230            array(
     231                'comment_post_ID'  => $p,
     232                'comment_content'  => '2',
     233                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     234            )
     235        );
     236        $comment_3 = self::factory()->comment->create(
     237            array(
     238                'comment_post_ID'  => $p,
     239                'comment_content'  => '3',
     240                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     241            )
     242        );
     243        $comment_4 = self::factory()->comment->create(
     244            array(
     245                'comment_post_ID'  => $p,
     246                'comment_content'  => '4',
     247                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     248            )
     249        );
     250        $comment_5 = self::factory()->comment->create(
     251            array(
     252                'comment_post_ID'  => $p,
     253                'comment_content'  => '3',
     254                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
     255            )
     256        );
     257        $comment_6 = self::factory()->comment->create(
     258            array(
     259                'comment_post_ID'  => $p,
     260                'comment_content'  => '4',
     261                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
     262            )
     263        );
    222264
    223265        update_option( 'comment_order', 'desc' );
     
    225267        update_option( 'page_comments', '1' );
    226268
    227         $link = add_query_arg( array(
    228             'cpage' => 2,
    229             'comments_per_page' => 2,
    230         ), get_permalink( $p ) );
     269        $link = add_query_arg(
     270            array(
     271                'cpage'             => 2,
     272                'comments_per_page' => 2,
     273            ), get_permalink( $p )
     274        );
    231275
    232276        $this->go_to( $link );
     
    244288     */
    245289    public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() {
    246         $now = time();
    247         $p = self::factory()->post->create();
    248         $comment_1 = self::factory()->comment->create( array(
    249             'comment_post_ID' => $p,
    250             'comment_content' => '1',
    251             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    252         ) );
    253         $comment_2 = self::factory()->comment->create( array(
    254             'comment_post_ID' => $p,
    255             'comment_content' => '2',
    256             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    257         ) );
    258         $comment_3 = self::factory()->comment->create( array(
    259             'comment_post_ID' => $p,
    260             'comment_content' => '3',
    261             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    262         ) );
    263         $comment_4 = self::factory()->comment->create( array(
    264             'comment_post_ID' => $p,
    265             'comment_content' => '4',
    266             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    267         ) );
     290        $now       = time();
     291        $p         = self::factory()->post->create();
     292        $comment_1 = self::factory()->comment->create(
     293            array(
     294                'comment_post_ID'  => $p,
     295                'comment_content'  => '1',
     296                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     297            )
     298        );
     299        $comment_2 = self::factory()->comment->create(
     300            array(
     301                'comment_post_ID'  => $p,
     302                'comment_content'  => '2',
     303                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     304            )
     305        );
     306        $comment_3 = self::factory()->comment->create(
     307            array(
     308                'comment_post_ID'  => $p,
     309                'comment_content'  => '3',
     310                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     311            )
     312        );
     313        $comment_4 = self::factory()->comment->create(
     314            array(
     315                'comment_post_ID'  => $p,
     316                'comment_content'  => '4',
     317                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     318            )
     319        );
    268320
    269321        update_option( 'comment_order', 'asc' );
     
    271323        update_option( 'page_comments', '1' );
    272324
    273         $link = add_query_arg( array(
    274             'cpage' => 2,
    275             'comments_per_page' => 2,
    276         ), get_permalink( $p ) );
     325        $link = add_query_arg(
     326            array(
     327                'cpage'             => 2,
     328                'comments_per_page' => 2,
     329            ), get_permalink( $p )
     330        );
    277331
    278332        $this->go_to( $link );
     
    290344     */
    291345    public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest_on_subsequent_pages() {
    292         $now = time();
    293         $p = self::factory()->post->create();
    294         $comment_1 = self::factory()->comment->create( array(
    295             'comment_post_ID' => $p,
    296             'comment_content' => '1',
    297             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    298         ) );
    299         $comment_2 = self::factory()->comment->create( array(
    300             'comment_post_ID' => $p,
    301             'comment_content' => '2',
    302             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    303         ) );
    304         $comment_3 = self::factory()->comment->create( array(
    305             'comment_post_ID' => $p,
    306             'comment_content' => '3',
    307             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    308         ) );
    309         $comment_4 = self::factory()->comment->create( array(
    310             'comment_post_ID' => $p,
    311             'comment_content' => '4',
    312             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    313         ) );
     346        $now       = time();
     347        $p         = self::factory()->post->create();
     348        $comment_1 = self::factory()->comment->create(
     349            array(
     350                'comment_post_ID'  => $p,
     351                'comment_content'  => '1',
     352                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     353            )
     354        );
     355        $comment_2 = self::factory()->comment->create(
     356            array(
     357                'comment_post_ID'  => $p,
     358                'comment_content'  => '2',
     359                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     360            )
     361        );
     362        $comment_3 = self::factory()->comment->create(
     363            array(
     364                'comment_post_ID'  => $p,
     365                'comment_content'  => '3',
     366                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     367            )
     368        );
     369        $comment_4 = self::factory()->comment->create(
     370            array(
     371                'comment_post_ID'  => $p,
     372                'comment_content'  => '4',
     373                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     374            )
     375        );
    314376
    315377        update_option( 'comment_order', 'desc' );
     
    317379        update_option( 'page_comments', '1' );
    318380
    319         $link = add_query_arg( array(
    320             'cpage' => 2,
    321             'comments_per_page' => 2,
    322         ), get_permalink( $p ) );
     381        $link = add_query_arg(
     382            array(
     383                'cpage'             => 2,
     384                'comments_per_page' => 2,
     385            ), get_permalink( $p )
     386        );
    323387
    324388        $this->go_to( $link );
     
    338402     */
    339403    public function test_last_page_of_comments_should_be_full_when_default_comment_page_is_newest() {
    340         $now = time();
    341         $p = self::factory()->post->create();
    342         $comment_1 = self::factory()->comment->create( array(
    343             'comment_post_ID' => $p,
    344             'comment_content' => '1',
    345             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    346         ) );
    347         $comment_2 = self::factory()->comment->create( array(
    348             'comment_post_ID' => $p,
    349             'comment_content' => '2',
    350             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    351         ) );
    352         $comment_3 = self::factory()->comment->create( array(
    353             'comment_post_ID' => $p,
    354             'comment_content' => '3',
    355             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    356         ) );
     404        $now       = time();
     405        $p         = self::factory()->post->create();
     406        $comment_1 = self::factory()->comment->create(
     407            array(
     408                'comment_post_ID'  => $p,
     409                'comment_content'  => '1',
     410                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     411            )
     412        );
     413        $comment_2 = self::factory()->comment->create(
     414            array(
     415                'comment_post_ID'  => $p,
     416                'comment_content'  => '2',
     417                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     418            )
     419        );
     420        $comment_3 = self::factory()->comment->create(
     421            array(
     422                'comment_post_ID'  => $p,
     423                'comment_content'  => '3',
     424                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     425            )
     426        );
    357427
    358428        update_option( 'default_comments_page', 'newest' );
     
    360430        update_option( 'page_comments', '1' );
    361431
    362         $link = add_query_arg( array(
    363             'cpage' => 1,
    364             'comments_per_page' => 2,
    365         ), get_permalink( $p ) );
     432        $link = add_query_arg(
     433            array(
     434                'cpage'             => 1,
     435                'comments_per_page' => 2,
     436            ), get_permalink( $p )
     437        );
    366438
    367439        $this->go_to( $link );
     
    381453     */
    382454    public function test_first_page_of_comments_should_have_remainder_when_default_comments_page_is_newest() {
    383         $now = time();
    384         $p = self::factory()->post->create();
    385         $comment_1 = self::factory()->comment->create( array(
    386             'comment_post_ID' => $p,
    387             'comment_content' => '1',
    388             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    389         ) );
    390         $comment_2 = self::factory()->comment->create( array(
    391             'comment_post_ID' => $p,
    392             'comment_content' => '2',
    393             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    394         ) );
    395         $comment_3 = self::factory()->comment->create( array(
    396             'comment_post_ID' => $p,
    397             'comment_content' => '3',
    398             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    399         ) );
     455        $now       = time();
     456        $p         = self::factory()->post->create();
     457        $comment_1 = self::factory()->comment->create(
     458            array(
     459                'comment_post_ID'  => $p,
     460                'comment_content'  => '1',
     461                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     462            )
     463        );
     464        $comment_2 = self::factory()->comment->create(
     465            array(
     466                'comment_post_ID'  => $p,
     467                'comment_content'  => '2',
     468                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     469            )
     470        );
     471        $comment_3 = self::factory()->comment->create(
     472            array(
     473                'comment_post_ID'  => $p,
     474                'comment_content'  => '3',
     475                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     476            )
     477        );
    400478
    401479        update_option( 'default_comments_page', 'newest' );
     
    403481        update_option( 'page_comments', '1' );
    404482
    405         $link = add_query_arg( array(
    406             'cpage' => 2,
    407             'comments_per_page' => 2,
    408         ), get_permalink( $p ) );
     483        $link = add_query_arg(
     484            array(
     485                'cpage'             => 2,
     486                'comments_per_page' => 2,
     487            ), get_permalink( $p )
     488        );
    409489
    410490        $this->go_to( $link );
     
    422502     */
    423503    public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_oldest() {
    424         $now = time();
    425         $p = self::factory()->post->create();
    426         $comment_1 = self::factory()->comment->create( array(
    427             'comment_post_ID' => $p,
    428             'comment_content' => '1',
    429             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    430         ) );
    431         $comment_2 = self::factory()->comment->create( array(
    432             'comment_post_ID' => $p,
    433             'comment_content' => '2',
    434             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    435         ) );
    436         $comment_3 = self::factory()->comment->create( array(
    437             'comment_post_ID' => $p,
    438             'comment_content' => '3',
    439             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    440         ) );
    441         $comment_4 = self::factory()->comment->create( array(
    442             'comment_post_ID' => $p,
    443             'comment_content' => '4',
    444             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    445         ) );
     504        $now       = time();
     505        $p         = self::factory()->post->create();
     506        $comment_1 = self::factory()->comment->create(
     507            array(
     508                'comment_post_ID'  => $p,
     509                'comment_content'  => '1',
     510                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     511            )
     512        );
     513        $comment_2 = self::factory()->comment->create(
     514            array(
     515                'comment_post_ID'  => $p,
     516                'comment_content'  => '2',
     517                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     518            )
     519        );
     520        $comment_3 = self::factory()->comment->create(
     521            array(
     522                'comment_post_ID'  => $p,
     523                'comment_content'  => '3',
     524                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     525            )
     526        );
     527        $comment_4 = self::factory()->comment->create(
     528            array(
     529                'comment_post_ID'  => $p,
     530                'comment_content'  => '4',
     531                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     532            )
     533        );
    446534
    447535        update_option( 'comment_order', 'desc' );
     
    449537        update_option( 'page_comments', '1' );
    450538
    451         $link_p1 = add_query_arg( array(
    452             'comments_per_page' => 2,
    453         ), get_permalink( $p ) );
     539        $link_p1 = add_query_arg(
     540            array(
     541                'comments_per_page' => 2,
     542            ), get_permalink( $p )
     543        );
    454544
    455545        $this->go_to( $link_p1 );
     
    465555        }
    466556
    467         $link_p2 = add_query_arg( array(
    468             'cpage' => 2,
    469             'comments_per_page' => 2,
    470         ), get_permalink( $p ) );
     557        $link_p2 = add_query_arg(
     558            array(
     559                'cpage'             => 2,
     560                'comments_per_page' => 2,
     561            ), get_permalink( $p )
     562        );
    471563
    472564        $this->go_to( $link_p2 );
     
    487579     */
    488580    public function test_comment_permalinks_should_be_correct_when_using_default_display_callback_with_default_comment_page_newest() {
    489         $now = time();
    490         $p = self::factory()->post->create();
    491         $comment_1 = self::factory()->comment->create( array(
    492             'comment_post_ID' => $p,
    493             'comment_content' => '1',
    494             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    495         ) );
    496         $comment_2 = self::factory()->comment->create( array(
    497             'comment_post_ID' => $p,
    498             'comment_content' => '2',
    499             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    500         ) );
    501         $comment_3 = self::factory()->comment->create( array(
    502             'comment_post_ID' => $p,
    503             'comment_content' => '3',
    504             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    505         ) );
    506         $comment_4 = self::factory()->comment->create( array(
    507             'comment_post_ID' => $p,
    508             'comment_content' => '4',
    509             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    510         ) );
    511         $comment_5 = self::factory()->comment->create( array(
    512             'comment_post_ID' => $p,
    513             'comment_content' => '4',
    514             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
    515         ) );
    516         $comment_6 = self::factory()->comment->create( array(
    517             'comment_post_ID' => $p,
    518             'comment_content' => '4',
    519             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
    520         ) );
     581        $now       = time();
     582        $p         = self::factory()->post->create();
     583        $comment_1 = self::factory()->comment->create(
     584            array(
     585                'comment_post_ID'  => $p,
     586                'comment_content'  => '1',
     587                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     588            )
     589        );
     590        $comment_2 = self::factory()->comment->create(
     591            array(
     592                'comment_post_ID'  => $p,
     593                'comment_content'  => '2',
     594                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     595            )
     596        );
     597        $comment_3 = self::factory()->comment->create(
     598            array(
     599                'comment_post_ID'  => $p,
     600                'comment_content'  => '3',
     601                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     602            )
     603        );
     604        $comment_4 = self::factory()->comment->create(
     605            array(
     606                'comment_post_ID'  => $p,
     607                'comment_content'  => '4',
     608                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     609            )
     610        );
     611        $comment_5 = self::factory()->comment->create(
     612            array(
     613                'comment_post_ID'  => $p,
     614                'comment_content'  => '4',
     615                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
     616            )
     617        );
     618        $comment_6 = self::factory()->comment->create(
     619            array(
     620                'comment_post_ID'  => $p,
     621                'comment_content'  => '4',
     622                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
     623            )
     624        );
    521625
    522626        update_option( 'comment_order', 'desc' );
     
    524628        update_option( 'page_comments', '1' );
    525629
    526         $link_p0 = add_query_arg( array(
    527             'comments_per_page' => 2,
    528         ), get_permalink( $p ) );
     630        $link_p0 = add_query_arg(
     631            array(
     632                'comments_per_page' => 2,
     633            ), get_permalink( $p )
     634        );
    529635
    530636        $this->go_to( $link_p0 );
     
    539645        }
    540646
    541         $link_p2 = add_query_arg( array(
    542             'cpage' => 2,
    543             'comments_per_page' => 2,
    544         ), get_permalink( $p ) );
     647        $link_p2 = add_query_arg(
     648            array(
     649                'cpage'             => 2,
     650                'comments_per_page' => 2,
     651            ), get_permalink( $p )
     652        );
    545653
    546654        $this->go_to( $link_p2 );
     
    557665
    558666        // p1 is the last page (neat!).
    559         $link_p1 = add_query_arg( array(
    560             'cpage' => 1,
    561             'comments_per_page' => 2,
    562         ), get_permalink( $p ) );
     667        $link_p1 = add_query_arg(
     668            array(
     669                'cpage'             => 1,
     670                'comments_per_page' => 2,
     671            ), get_permalink( $p )
     672        );
    563673
    564674        $this->go_to( $link_p1 );
     
    579689     */
    580690    public function test_query_offset_should_not_include_unapproved_comments() {
    581         $now = time();
    582         $p = self::factory()->post->create();
    583         $comment_1 = self::factory()->comment->create( array(
    584             'comment_post_ID' => $p,
    585             'comment_content' => '1',
    586             'comment_approved' => '0',
    587             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    588         ) );
    589         $comment_2 = self::factory()->comment->create( array(
    590             'comment_post_ID' => $p,
    591             'comment_content' => '2',
    592             'comment_approved' => '0',
    593             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    594         ) );
    595         $comment_3 = self::factory()->comment->create( array(
    596             'comment_post_ID' => $p,
    597             'comment_content' => '3',
    598             'comment_approved' => '0',
    599             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    600         ) );
    601         $comment_4 = self::factory()->comment->create( array(
    602             'comment_post_ID' => $p,
    603             'comment_content' => '4',
    604             'comment_approved' => '1',
    605             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    606         ) );
     691        $now       = time();
     692        $p         = self::factory()->post->create();
     693        $comment_1 = self::factory()->comment->create(
     694            array(
     695                'comment_post_ID'  => $p,
     696                'comment_content'  => '1',
     697                'comment_approved' => '0',
     698                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     699            )
     700        );
     701        $comment_2 = self::factory()->comment->create(
     702            array(
     703                'comment_post_ID'  => $p,
     704                'comment_content'  => '2',
     705                'comment_approved' => '0',
     706                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     707            )
     708        );
     709        $comment_3 = self::factory()->comment->create(
     710            array(
     711                'comment_post_ID'  => $p,
     712                'comment_content'  => '3',
     713                'comment_approved' => '0',
     714                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     715            )
     716        );
     717        $comment_4 = self::factory()->comment->create(
     718            array(
     719                'comment_post_ID'  => $p,
     720                'comment_content'  => '4',
     721                'comment_approved' => '1',
     722                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     723            )
     724        );
    607725
    608726        update_option( 'comment_order', 'asc' );
     
    627745        $comment_author_email = 'foo@example.com';
    628746
    629         $now = time();
    630         $p = self::factory()->post->create();
    631         $comment_1 = self::factory()->comment->create( array(
    632             'comment_post_ID' => $p,
    633             'comment_content' => '1',
    634             'comment_approved' => '0',
    635             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    636         ) );
    637         $comment_2 = self::factory()->comment->create( array(
    638             'comment_post_ID' => $p,
    639             'comment_content' => '2',
    640             'comment_approved' => '0',
    641             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    642         ) );
    643         $comment_3 = self::factory()->comment->create( array(
    644             'comment_post_ID' => $p,
    645             'comment_content' => '3',
    646             'comment_approved' => '0',
    647             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    648             'comment_author_email' => $comment_author_email,
    649         ) );
    650         $comment_4 = self::factory()->comment->create( array(
    651             'comment_post_ID' => $p,
    652             'comment_content' => '4',
    653             'comment_approved' => '0',
    654             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    655             'comment_author_email' => $comment_author_email,
    656         ) );
    657         $comment_5 = self::factory()->comment->create( array(
    658             'comment_post_ID' => $p,
    659             'comment_content' => '5',
    660             'comment_approved' => '0',
    661             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    662             'comment_author_email' => $comment_author_email,
    663         ) );
    664         $comment_6 = self::factory()->comment->create( array(
    665             'comment_post_ID' => $p,
    666             'comment_content' => '6',
    667             'comment_approved' => '1',
    668             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
    669         ) );
     747        $now       = time();
     748        $p         = self::factory()->post->create();
     749        $comment_1 = self::factory()->comment->create(
     750            array(
     751                'comment_post_ID'  => $p,
     752                'comment_content'  => '1',
     753                'comment_approved' => '0',
     754                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     755            )
     756        );
     757        $comment_2 = self::factory()->comment->create(
     758            array(
     759                'comment_post_ID'  => $p,
     760                'comment_content'  => '2',
     761                'comment_approved' => '0',
     762                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     763            )
     764        );
     765        $comment_3 = self::factory()->comment->create(
     766            array(
     767                'comment_post_ID'      => $p,
     768                'comment_content'      => '3',
     769                'comment_approved'     => '0',
     770                'comment_date_gmt'     => date( 'Y-m-d H:i:s', $now - 100 ),
     771                'comment_author_email' => $comment_author_email,
     772            )
     773        );
     774        $comment_4 = self::factory()->comment->create(
     775            array(
     776                'comment_post_ID'      => $p,
     777                'comment_content'      => '4',
     778                'comment_approved'     => '0',
     779                'comment_date_gmt'     => date( 'Y-m-d H:i:s', $now - 200 ),
     780                'comment_author_email' => $comment_author_email,
     781            )
     782        );
     783        $comment_5 = self::factory()->comment->create(
     784            array(
     785                'comment_post_ID'      => $p,
     786                'comment_content'      => '5',
     787                'comment_approved'     => '0',
     788                'comment_date_gmt'     => date( 'Y-m-d H:i:s', $now - 300 ),
     789                'comment_author_email' => $comment_author_email,
     790            )
     791        );
     792        $comment_6 = self::factory()->comment->create(
     793            array(
     794                'comment_post_ID'  => $p,
     795                'comment_content'  => '6',
     796                'comment_approved' => '1',
     797                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
     798            )
     799        );
    670800
    671801        update_option( 'comment_order', 'asc' );
     
    695825     */
    696826    public function test_hierarchy_should_be_ignored_when_threading_is_disabled() {
    697         $now = time();
    698         $p = self::factory()->post->create();
    699         $comment_1 = self::factory()->comment->create( array(
    700             'comment_post_ID' => $p,
    701             'comment_content' => '1',
    702             'comment_approved' => '1',
    703             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    704         ) );
    705         $comment_2 = self::factory()->comment->create( array(
    706             'comment_post_ID' => $p,
    707             'comment_content' => '2',
    708             'comment_approved' => '1',
    709             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    710         ) );
    711         $comment_3 = self::factory()->comment->create( array(
    712             'comment_post_ID' => $p,
    713             'comment_content' => '3',
    714             'comment_approved' => '1',
    715             'comment_parent' => $comment_1,
    716             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    717         ) );
     827        $now       = time();
     828        $p         = self::factory()->post->create();
     829        $comment_1 = self::factory()->comment->create(
     830            array(
     831                'comment_post_ID'  => $p,
     832                'comment_content'  => '1',
     833                'comment_approved' => '1',
     834                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     835            )
     836        );
     837        $comment_2 = self::factory()->comment->create(
     838            array(
     839                'comment_post_ID'  => $p,
     840                'comment_content'  => '2',
     841                'comment_approved' => '1',
     842                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     843            )
     844        );
     845        $comment_3 = self::factory()->comment->create(
     846            array(
     847                'comment_post_ID'  => $p,
     848                'comment_content'  => '3',
     849                'comment_approved' => '1',
     850                'comment_parent'   => $comment_1,
     851                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     852            )
     853        );
    718854
    719855        update_option( 'comment_order', 'asc' );
     
    734870     */
    735871    public function test_pagination_calculation_should_ignore_comment_hierarchy_when_threading_is_disabled() {
    736         $now = time();
    737         $p = self::factory()->post->create();
    738         $comment_1 = self::factory()->comment->create( array(
    739             'comment_post_ID' => $p,
    740             'comment_content' => '1',
    741             'comment_approved' => '1',
    742             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
    743         ) );
    744         $comment_2 = self::factory()->comment->create( array(
    745             'comment_post_ID' => $p,
    746             'comment_content' => '2',
    747             'comment_approved' => '1',
    748             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
    749         ) );
    750         $comment_3 = self::factory()->comment->create( array(
    751             'comment_post_ID' => $p,
    752             'comment_content' => '3',
    753             'comment_approved' => '1',
    754             'comment_parent' => $comment_1,
    755             'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
    756         ) );
     872        $now       = time();
     873        $p         = self::factory()->post->create();
     874        $comment_1 = self::factory()->comment->create(
     875            array(
     876                'comment_post_ID'  => $p,
     877                'comment_content'  => '1',
     878                'comment_approved' => '1',
     879                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
     880            )
     881        );
     882        $comment_2 = self::factory()->comment->create(
     883            array(
     884                'comment_post_ID'  => $p,
     885                'comment_content'  => '2',
     886                'comment_approved' => '1',
     887                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
     888            )
     889        );
     890        $comment_3 = self::factory()->comment->create(
     891            array(
     892                'comment_post_ID'  => $p,
     893                'comment_content'  => '3',
     894                'comment_approved' => '1',
     895                'comment_parent'   => $comment_1,
     896                'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
     897            )
     898        );
    757899
    758900        update_option( 'thread_comments', 0 );
Note: See TracChangeset for help on using the changeset viewer.