Code Duplication    Length = 10-13 lines in 8 locations

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

@@ 1447-1456 (lines=10) @@
1444
        $this->assertContains("ORDER BY $wpdb->comments.comment_date_gmt", $q->request);
1445
    }
1446
1447
    public function test_orderby_single() 
1448
    {
1449
        global $wpdb;
1450
1451
        $q = new WP_Comment_Query();
1452
        $q->query(
1453
            array(
1454
            'orderby' => 'comment_agent',
1455
            ) 
1456
        );
1457
1458
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent", $q->request);
1459
    }
@@ 1461-1470 (lines=10) @@
1458
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent", $q->request);
1459
    }
1460
1461
    public function test_orderby_single_invalid() 
1462
    {
1463
        global $wpdb;
1464
1465
        $q = new WP_Comment_Query();
1466
        $q->query(
1467
            array(
1468
            'orderby' => 'foo',
1469
            ) 
1470
        );
1471
1472
        $this->assertContains("ORDER BY $wpdb->comments.comment_date_gmt", $q->request);
1473
    }
@@ 1475-1484 (lines=10) @@
1472
        $this->assertContains("ORDER BY $wpdb->comments.comment_date_gmt", $q->request);
1473
    }
1474
1475
    public function test_orderby_space_separated() 
1476
    {
1477
        global $wpdb;
1478
1479
        $q = new WP_Comment_Query();
1480
        $q->query(
1481
            array(
1482
            'orderby' => 'comment_agent comment_approved',
1483
            ) 
1484
        );
1485
1486
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1487
    }
@@ 1489-1498 (lines=10) @@
1486
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1487
    }
1488
1489
    public function test_orderby_comma_separated() 
1490
    {
1491
        global $wpdb;
1492
1493
        $q = new WP_Comment_Query();
1494
        $q->query(
1495
            array(
1496
            'orderby' => 'comment_agent, comment_approved',
1497
            ) 
1498
        );
1499
1500
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1501
    }
@@ 1503-1512 (lines=10) @@
1500
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1501
    }
1502
1503
    public function test_orderby_flat_array() 
1504
    {
1505
        global $wpdb;
1506
1507
        $q = new WP_Comment_Query();
1508
        $q->query(
1509
            array(
1510
            'orderby' => array( 'comment_agent', 'comment_approved' ),
1511
            ) 
1512
        );
1513
1514
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1515
    }
@@ 1517-1526 (lines=10) @@
1514
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1515
    }
1516
1517
    public function test_orderby_array_contains_invalid_item() 
1518
    {
1519
        global $wpdb;
1520
1521
        $q = new WP_Comment_Query();
1522
        $q->query(
1523
            array(
1524
            'orderby' => array( 'comment_agent', 'foo', 'comment_approved' ),
1525
            ) 
1526
        );
1527
1528
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1529
    }
@@ 1531-1540 (lines=10) @@
1528
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_approved DESC", $q->request);
1529
    }
1530
1531
    public function test_orderby_array_contains_all_invalid_items() 
1532
    {
1533
        global $wpdb;
1534
1535
        $q = new WP_Comment_Query();
1536
        $q->query(
1537
            array(
1538
            'orderby' => array( 'foo', 'bar', 'baz' ),
1539
            ) 
1540
        );
1541
1542
        $this->assertContains("ORDER BY $wpdb->comments.comment_date_gmt", $q->request);
1543
    }
@@ 1701-1713 (lines=13) @@
1698
    /**
1699
     * @ticket 30478
1700
     */
1701
    public function test_orderby_array_should_sort_by_comment_ID_DESC_as_fallback_when_not_sorted_by_date() 
1702
    {
1703
        global $wpdb;
1704
1705
        $q = new WP_Comment_Query();
1706
        $found = $q->query(
1707
            array(
1708
            'fields' => 'ids',
1709
            'orderby' => array(
1710
            'comment_agent' => 'ASC',
1711
            ),
1712
            ) 
1713
        );
1714
1715
        $this->assertContains("ORDER BY $wpdb->comments.comment_agent ASC, $wpdb->comments.comment_ID DESC", $q->request);
1716
    }