Changeset 42343 for trunk/tests/phpunit/tests/comment/metaCache.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/comment/metaCache.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/metaCache.php
r37954 r42343 2 2 3 3 class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 4 protected $i = 0;4 protected $i = 0; 5 5 protected $queries = 0; 6 6 … … 11 11 global $wpdb; 12 12 13 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );13 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 14 14 $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); 15 15 … … 21 21 clean_comment_cache( $comment_ids ); 22 22 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 ); 26 28 27 29 $num_queries = $wpdb->num_queries; … … 39 41 global $wpdb; 40 42 41 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );43 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 42 44 $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); 43 45 … … 49 51 clean_comment_cache( $comment_ids ); 50 52 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 ); 55 59 56 60 $num_queries = $wpdb->num_queries; … … 68 72 global $wpdb; 69 73 70 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );74 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 71 75 $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); 72 76 … … 75 79 } 76 80 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 ); 81 87 82 88 $num_queries = $wpdb->num_queries; … … 94 100 global $wpdb; 95 101 96 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) );102 $p = self::factory()->post->create( array( 'post_status' => 'publish' ) ); 97 103 $comment_ids = self::factory()->comment->create_post_comments( $p, 3 ); 98 104 … … 131 137 $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) ); 132 138 133 $now = time();139 $now = time(); 134 140 $comments = array(); 135 141 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 ); 140 148 } 141 149 … … 146 154 update_option( 'posts_per_rss', 3 ); 147 155 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 ); 152 162 153 163 // First comment will cause the cache to be primed. … … 175 185 $posts = self::factory()->post->create_many( 2, array( 'post_status' => 'publish' ) ); 176 186 177 $now = time();187 $now = time(); 178 188 $comments = array(); 179 189 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 ); 184 196 } 185 197 … … 190 202 update_option( 'posts_per_rss', 3 ); 191 203 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 ); 197 211 198 212 // First comment will cause the cache to be primed.
Note: See TracChangeset
for help on using the changeset viewer.