Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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/metaCache.php

    r37954 r42343  
    22
    33class Tests_Comment_Meta_Cache extends WP_UnitTestCase {
    4     protected $i = 0;
     4    protected $i       = 0;
    55    protected $queries = 0;
    66
     
    1111        global $wpdb;
    1212
    13         $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     13        $p           = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    1414        $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    1515
     
    2121        clean_comment_cache( $comment_ids );
    2222
    23         $q = new WP_Comment_Query( array(
    24             'post_ID' => $p,
    25         ) );
     23        $q = new WP_Comment_Query(
     24            array(
     25                'post_ID' => $p,
     26            )
     27        );
    2628
    2729        $num_queries = $wpdb->num_queries;
     
    3941        global $wpdb;
    4042
    41         $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     43        $p           = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    4244        $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    4345
     
    4951        clean_comment_cache( $comment_ids );
    5052
    51         $q = new WP_Comment_Query( array(
    52             'post_ID' => $p,
    53             'update_comment_meta_cache' => true,
    54         ) );
     53        $q = new WP_Comment_Query(
     54            array(
     55                'post_ID'                   => $p,
     56                'update_comment_meta_cache' => true,
     57            )
     58        );
    5559
    5660        $num_queries = $wpdb->num_queries;
     
    6872        global $wpdb;
    6973
    70         $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     74        $p           = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    7175        $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    7276
     
    7579        }
    7680
    77         $q = new WP_Comment_Query( array(
    78             'post_ID' => $p,
    79             'update_comment_meta_cache' => false,
    80         ) );
     81        $q = new WP_Comment_Query(
     82            array(
     83                'post_ID'                   => $p,
     84                'update_comment_meta_cache' => false,
     85            )
     86        );
    8187
    8288        $num_queries = $wpdb->num_queries;
     
    94100        global $wpdb;
    95101
    96         $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );
     102        $p           = self::factory()->post->create( array( 'post_status' => 'publish' ) );
    97103        $comment_ids = self::factory()->comment->create_post_comments( $p, 3 );
    98104
     
    131137        $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) );
    132138
    133         $now = time();
     139        $now      = time();
    134140        $comments = array();
    135141        for ( $i = 0; $i < 5; $i++ ) {
    136             $comments[] = self::factory()->comment->create( array(
    137                 'comment_post_ID' => $posts[0],
    138                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
    139             ) );
     142            $comments[] = self::factory()->comment->create(
     143                array(
     144                    'comment_post_ID'  => $posts[0],
     145                    'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
     146                )
     147            );
    140148        }
    141149
     
    146154        update_option( 'posts_per_rss', 3 );
    147155
    148         $q = new WP_Query( array(
    149             'feed' => true,
    150             'withcomments' => true,
    151         ) );
     156        $q = new WP_Query(
     157            array(
     158                'feed'         => true,
     159                'withcomments' => true,
     160            )
     161        );
    152162
    153163        // First comment will cause the cache to be primed.
     
    175185        $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) );
    176186
    177         $now = time();
     187        $now      = time();
    178188        $comments = array();
    179189        for ( $i = 0; $i < 5; $i++ ) {
    180             $comments[] = self::factory()->comment->create( array(
    181                 'comment_post_ID' => $posts[0],
    182                 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
    183             ) );
     190            $comments[] = self::factory()->comment->create(
     191                array(
     192                    'comment_post_ID'  => $posts[0],
     193                    'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( 60 * $i ) ),
     194                )
     195            );
    184196        }
    185197
     
    190202        update_option( 'posts_per_rss', 3 );
    191203
    192         $q = new WP_Query( array(
    193             'feed' => true,
    194             'withcomments' => true,
    195             'p' => $posts[0],
    196         ) );
     204        $q = new WP_Query(
     205            array(
     206                'feed'         => true,
     207                'withcomments' => true,
     208                'p'            => $posts[0],
     209            )
     210        );
    197211
    198212        // First comment will cause the cache to be primed.
Note: See TracChangeset for help on using the changeset viewer.