| @@ 1593-1607 (lines=15) @@ | ||
| 1590 | /** |
|
| 1591 | * @ticket 30478 |
|
| 1592 | */ |
|
| 1593 | public function test_orderby_array() |
|
| 1594 | { |
|
| 1595 | global $wpdb; |
|
| 1596 | ||
| 1597 | $q = new WP_Comment_Query(); |
|
| 1598 | $found = $q->query( |
|
| 1599 | array( |
|
| 1600 | 'fields' => 'ids', |
|
| 1601 | 'orderby' => array( |
|
| 1602 | 'comment_agent' => 'DESC', |
|
| 1603 | 'comment_date_gmt' => 'ASC', |
|
| 1604 | 'comment_ID' => 'DESC', |
|
| 1605 | ), |
|
| 1606 | ) |
|
| 1607 | ); |
|
| 1608 | ||
| 1609 | $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date_gmt ASC, $wpdb->comments.comment_ID DESC", $q->request); |
|
| 1610 | } |
|
| @@ 1615-1629 (lines=15) @@ | ||
| 1612 | /** |
|
| 1613 | * @ticket 30478 |
|
| 1614 | */ |
|
| 1615 | public function test_orderby_array_should_discard_invalid_columns() |
|
| 1616 | { |
|
| 1617 | global $wpdb; |
|
| 1618 | ||
| 1619 | $q = new WP_Comment_Query(); |
|
| 1620 | $found = $q->query( |
|
| 1621 | array( |
|
| 1622 | 'fields' => 'ids', |
|
| 1623 | 'orderby' => array( |
|
| 1624 | 'comment_agent' => 'DESC', |
|
| 1625 | 'foo' => 'ASC', |
|
| 1626 | 'comment_ID' => 'DESC', |
|
| 1627 | ), |
|
| 1628 | ) |
|
| 1629 | ); |
|
| 1630 | ||
| 1631 | $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_ID DESC", $q->request); |
|
| 1632 | } |
|
| @@ 1637-1651 (lines=15) @@ | ||
| 1634 | /** |
|
| 1635 | * @ticket 30478 |
|
| 1636 | */ |
|
| 1637 | public function test_orderby_array_should_convert_invalid_order_to_DESC() |
|
| 1638 | { |
|
| 1639 | global $wpdb; |
|
| 1640 | ||
| 1641 | $q = new WP_Comment_Query(); |
|
| 1642 | $found = $q->query( |
|
| 1643 | array( |
|
| 1644 | 'fields' => 'ids', |
|
| 1645 | 'orderby' => array( |
|
| 1646 | 'comment_agent' => 'DESC', |
|
| 1647 | 'comment_date_gmt' => 'foo', |
|
| 1648 | 'comment_ID' => 'DESC', |
|
| 1649 | ), |
|
| 1650 | ) |
|
| 1651 | ); |
|
| 1652 | ||
| 1653 | $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date_gmt DESC, $wpdb->comments.comment_ID DESC", $q->request); |
|
| 1654 | } |
|
| @@ 1659-1672 (lines=14) @@ | ||
| 1656 | /** |
|
| 1657 | * @ticket 30478 |
|
| 1658 | */ |
|
| 1659 | public function test_orderby_array_should_sort_by_comment_ID_as_fallback_and_should_inherit_order_from_comment_date_gmt() |
|
| 1660 | { |
|
| 1661 | global $wpdb; |
|
| 1662 | ||
| 1663 | $q = new WP_Comment_Query(); |
|
| 1664 | $found = $q->query( |
|
| 1665 | array( |
|
| 1666 | 'fields' => 'ids', |
|
| 1667 | 'orderby' => array( |
|
| 1668 | 'comment_agent' => 'DESC', |
|
| 1669 | 'comment_date_gmt' => 'ASC', |
|
| 1670 | ), |
|
| 1671 | ) |
|
| 1672 | ); |
|
| 1673 | ||
| 1674 | $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date_gmt ASC, $wpdb->comments.comment_ID ASC", $q->request); |
|
| 1675 | } |
|
| @@ 1680-1693 (lines=14) @@ | ||
| 1677 | /** |
|
| 1678 | * @ticket 30478 |
|
| 1679 | */ |
|
| 1680 | public function test_orderby_array_should_sort_by_comment_ID_as_fallback_and_should_inherit_order_from_comment_date() |
|
| 1681 | { |
|
| 1682 | global $wpdb; |
|
| 1683 | ||
| 1684 | $q = new WP_Comment_Query(); |
|
| 1685 | $found = $q->query( |
|
| 1686 | array( |
|
| 1687 | 'fields' => 'ids', |
|
| 1688 | 'orderby' => array( |
|
| 1689 | 'comment_agent' => 'DESC', |
|
| 1690 | 'comment_date' => 'ASC', |
|
| 1691 | ), |
|
| 1692 | ) |
|
| 1693 | ); |
|
| 1694 | ||
| 1695 | $this->assertContains("ORDER BY $wpdb->comments.comment_agent DESC, $wpdb->comments.comment_date ASC, $wpdb->comments.comment_ID ASC", $q->request); |
|
| 1696 | } |
|