| @@ 3072-3085 (lines=14) @@ | ||
| 3069 | /** |
|
| 3070 | * @ticket 27571 |
|
| 3071 | */ |
|
| 3072 | public function test_update_comment_post_cache_should_be_disabled_by_default() |
|
| 3073 | { |
|
| 3074 | global $wpdb; |
|
| 3075 | ||
| 3076 | $p = self::factory()->post->create(); |
|
| 3077 | $c = self::factory()->comment->create(array( 'comment_post_ID' => $p )); |
|
| 3078 | ||
| 3079 | $q = new WP_Comment_Query( |
|
| 3080 | array( |
|
| 3081 | 'post_ID' => $p, |
|
| 3082 | ) |
|
| 3083 | ); |
|
| 3084 | ||
| 3085 | $num_queries = $wpdb->num_queries; |
|
| 3086 | $this->assertTrue(isset($q->comments[0]->post_name)); |
|
| 3087 | $this->assertSame($num_queries + 1, $wpdb->num_queries); |
|
| 3088 | } |
|
| @@ 3093-3107 (lines=15) @@ | ||
| 3090 | /** |
|
| 3091 | * @ticket 27571 |
|
| 3092 | */ |
|
| 3093 | public function test_should_respect_update_comment_post_cache_true() |
|
| 3094 | { |
|
| 3095 | global $wpdb; |
|
| 3096 | ||
| 3097 | $p = self::factory()->post->create(); |
|
| 3098 | $c = self::factory()->comment->create(array( 'comment_post_ID' => $p )); |
|
| 3099 | ||
| 3100 | $q = new WP_Comment_Query( |
|
| 3101 | array( |
|
| 3102 | 'post_ID' => $p, |
|
| 3103 | 'update_comment_post_cache' => true, |
|
| 3104 | ) |
|
| 3105 | ); |
|
| 3106 | ||
| 3107 | $num_queries = $wpdb->num_queries; |
|
| 3108 | $this->assertTrue(isset($q->comments[0]->post_name)); |
|
| 3109 | $this->assertSame($num_queries, $wpdb->num_queries); |
|
| 3110 | } |
|