Code Duplication    Length = 26-28 lines in 5 locations

tests/phpunit/tests/comment/query.php 5 locations

@@ 3257-3282 (lines=26) @@
3254
        $this->assertEqualSets(array( $c ), $q->comments);
3255
    }
3256
3257
    public function test_deleted_comment_should_invalidate_query_cache() 
3258
    {
3259
        global $wpdb;
3260
3261
        $c = self::factory()->comment->create(
3262
            array(
3263
            'comment_post_ID' => self::$post_id,
3264
            'comment_approved' => '1',
3265
            ) 
3266
        );
3267
3268
        $q = new WP_Comment_Query(
3269
            array(
3270
            'post_id' => self::$post_id,
3271
            'fields' => 'ids',
3272
            ) 
3273
        );
3274
3275
        wp_delete_comment($c);
3276
3277
        $num_queries = $wpdb->num_queries;
3278
3279
        $q = new WP_Comment_Query(
3280
            array(
3281
            'post_id' => self::$post_id,
3282
            'fields' => 'ids',
3283
            ) 
3284
        );
3285
@@ 3291-3316 (lines=26) @@
3288
        $this->assertEqualSets(array(), $q->comments);
3289
    }
3290
3291
    public function test_trashed_comment_should_invalidate_query_cache() 
3292
    {
3293
        global $wpdb;
3294
3295
        $c = self::factory()->comment->create(
3296
            array(
3297
            'comment_post_ID' => self::$post_id,
3298
            'comment_approved' => '1',
3299
            ) 
3300
        );
3301
3302
        $q = new WP_Comment_Query(
3303
            array(
3304
            'post_id' => self::$post_id,
3305
            'fields' => 'ids',
3306
            ) 
3307
        );
3308
3309
        wp_trash_comment($c);
3310
3311
        $num_queries = $wpdb->num_queries;
3312
3313
        $q = new WP_Comment_Query(
3314
            array(
3315
            'post_id' => self::$post_id,
3316
            'fields' => 'ids',
3317
            ) 
3318
        );
3319
@@ 3325-3352 (lines=28) @@
3322
        $this->assertEqualSets(array(), $q->comments);
3323
    }
3324
3325
    public function test_untrashed_comment_should_invalidate_query_cache() 
3326
    {
3327
        global $wpdb;
3328
3329
        $c = self::factory()->comment->create(
3330
            array(
3331
            'comment_post_ID' => self::$post_id,
3332
            'comment_approved' => '1',
3333
            ) 
3334
        );
3335
3336
        wp_trash_comment($c);
3337
3338
        $q = new WP_Comment_Query(
3339
            array(
3340
            'post_id' => self::$post_id,
3341
            'fields' => 'ids',
3342
            ) 
3343
        );
3344
3345
        wp_untrash_comment($c);
3346
3347
        $num_queries = $wpdb->num_queries;
3348
3349
        $q = new WP_Comment_Query(
3350
            array(
3351
            'post_id' => self::$post_id,
3352
            'fields' => 'ids',
3353
            ) 
3354
        );
3355
@@ 3361-3386 (lines=26) @@
3358
        $this->assertEqualSets(array( $c ), $q->comments);
3359
    }
3360
3361
    public function test_spammed_comment_should_invalidate_query_cache() 
3362
    {
3363
        global $wpdb;
3364
3365
        $c = self::factory()->comment->create(
3366
            array(
3367
            'comment_post_ID' => self::$post_id,
3368
            'comment_approved' => '1',
3369
            ) 
3370
        );
3371
3372
        $q = new WP_Comment_Query(
3373
            array(
3374
            'post_id' => self::$post_id,
3375
            'fields' => 'ids',
3376
            ) 
3377
        );
3378
3379
        wp_spam_comment($c);
3380
3381
        $num_queries = $wpdb->num_queries;
3382
3383
        $q = new WP_Comment_Query(
3384
            array(
3385
            'post_id' => self::$post_id,
3386
            'fields' => 'ids',
3387
            ) 
3388
        );
3389
@@ 3395-3422 (lines=28) @@
3392
        $this->assertEqualSets(array(), $q->comments);
3393
    }
3394
3395
    public function test_unspammed_comment_should_invalidate_query_cache() 
3396
    {
3397
        global $wpdb;
3398
3399
        $c = self::factory()->comment->create(
3400
            array(
3401
            'comment_post_ID' => self::$post_id,
3402
            'comment_approved' => '1',
3403
            ) 
3404
        );
3405
3406
        wp_spam_comment($c);
3407
3408
        $q = new WP_Comment_Query(
3409
            array(
3410
            'post_id' => self::$post_id,
3411
            'fields' => 'ids',
3412
            ) 
3413
        );
3414
3415
        wp_unspam_comment($c);
3416
3417
        $num_queries = $wpdb->num_queries;
3418
3419
        $q = new WP_Comment_Query(
3420
            array(
3421
            'post_id' => self::$post_id,
3422
            'fields' => 'ids',
3423
            ) 
3424
        );
3425