Code Duplication    Length = 16-17 lines in 6 locations

tests/phpunit/tests/query/conditionals.php 6 locations

@@ 386-402 (lines=17) @@
383
384
    // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
385
    // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]',
386
    function test_category_feed() 
387
    {
388
        self::factory()->term->create(array( 'name' => 'cat-a', 'taxonomy' => 'category' ));
389
390
        // check the long form
391
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
392
        foreach ($types as $type) {
393
            $this->go_to("/category/cat-a/feed/{$type}");
394
            $this->assertQueryTrue('is_archive', 'is_feed', 'is_category');
395
        }
396
397
        // check the short form
398
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
399
        foreach ($types as $type) {
400
            $this->go_to("/category/cat-a/{$type}");
401
            $this->assertQueryTrue('is_archive', 'is_feed', 'is_category');
402
        }
403
    }
404
405
    // 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]',
@@ 424-439 (lines=16) @@
421
422
    // 'tag/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
423
    // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]',
424
    function test_tag_feed() 
425
    {
426
        self::factory()->term->create(array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ));
427
        // check the long form
428
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
429
        foreach ($types as $type) {
430
             $this->go_to("/tag/tag-a/feed/{$type}");
431
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_tag');
432
        }
433
434
        // check the short form
435
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
436
        foreach ($types as $type) {
437
             $this->go_to("/tag/tag-a/{$type}");
438
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_tag');
439
        }
440
    }
441
442
    // 'tag/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]',
@@ 475-490 (lines=16) @@
472
473
    // 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
474
    // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
475
    function test_author_feed() 
476
    {
477
        self::factory()->user->create(array( 'user_login' => 'user-a' ));
478
        // check the long form
479
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
480
        foreach ($types as $type) {
481
             $this->go_to("/author/user-a/feed/{$type}");
482
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_author');
483
        }
484
485
        // check the short form
486
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
487
        foreach ($types as $type) {
488
             $this->go_to("/author/user-a/{$type}");
489
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_author');
490
        }
491
    }
492
493
    // 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]',
@@ 521-536 (lines=16) @@
518
519
    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
520
    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]',
521
    function test_ymd_feed() 
522
    {
523
        self::factory()->post->create(array( 'post_date' => '2007-09-04 00:00:00' ));
524
        // check the long form
525
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
526
        foreach ($types as $type) {
527
             $this->go_to("/2007/09/04/feed/{$type}");
528
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_day', 'is_date');
529
        }
530
531
        // check the short form
532
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
533
        foreach ($types as $type) {
534
             $this->go_to("/2007/09/04/{$type}");
535
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_day', 'is_date');
536
        }
537
    }
538
539
    // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]',
@@ 558-573 (lines=16) @@
555
556
    // '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
557
    // '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]',
558
    function test_ym_feed() 
559
    {
560
        self::factory()->post->create(array( 'post_date' => '2007-09-04 00:00:00' ));
561
        // check the long form
562
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
563
        foreach ($types as $type) {
564
             $this->go_to("/2007/09/feed/{$type}");
565
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_month', 'is_date');
566
        }
567
568
        // check the short form
569
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
570
        foreach ($types as $type) {
571
             $this->go_to("/2007/09/{$type}");
572
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_month', 'is_date');
573
        }
574
    }
575
576
    // '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]',
@@ 595-610 (lines=16) @@
592
593
    // '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
594
    // '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]',
595
    function test_y_feed() 
596
    {
597
        self::factory()->post->create(array( 'post_date' => '2007-09-04 00:00:00' ));
598
        // check the long form
599
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
600
        foreach ($types as $type) {
601
             $this->go_to("/2007/feed/{$type}");
602
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_year', 'is_date');
603
        }
604
605
        // check the short form
606
        $types = array('feed', 'rdf', 'rss', 'rss2', 'atom');
607
        foreach ($types as $type) {
608
             $this->go_to("/2007/{$type}");
609
             $this->assertQueryTrue('is_archive', 'is_feed', 'is_year', 'is_date');
610
        }
611
    }
612
613
    // '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]',