| @@ 780-800 (lines=21) @@ | ||
| 777 | /** |
|
| 778 | * @ticket 30478 |
|
| 779 | */ |
|
| 780 | public function test_orderby_clause_key() |
|
| 781 | { |
|
| 782 | $comments = self::factory()->comment->create_many(3); |
|
| 783 | add_comment_meta($comments[0], 'foo', 'aaa'); |
|
| 784 | add_comment_meta($comments[1], 'foo', 'zzz'); |
|
| 785 | add_comment_meta($comments[2], 'foo', 'jjj'); |
|
| 786 | ||
| 787 | $q = new WP_Comment_Query(); |
|
| 788 | $found = $q->query( |
|
| 789 | array( |
|
| 790 | 'fields' => 'ids', |
|
| 791 | 'meta_query' => array( |
|
| 792 | 'foo_key' => array( |
|
| 793 | 'key' => 'foo', |
|
| 794 | 'compare' => 'EXISTS', |
|
| 795 | ), |
|
| 796 | ), |
|
| 797 | 'orderby' => 'foo_key', |
|
| 798 | 'order' => 'DESC', |
|
| 799 | ) |
|
| 800 | ); |
|
| 801 | ||
| 802 | $this->assertEquals(array( $comments[1], $comments[2], $comments[0] ), $found); |
|
| 803 | } |
|
| @@ 1745-1764 (lines=20) @@ | ||
| 1742 | /** |
|
| 1743 | * @ticket 31045 |
|
| 1744 | */ |
|
| 1745 | public function test_orderby_clause_key() |
|
| 1746 | { |
|
| 1747 | $posts = self::factory()->post->create_many(3); |
|
| 1748 | add_post_meta($posts[0], 'foo', 'aaa'); |
|
| 1749 | add_post_meta($posts[1], 'foo', 'zzz'); |
|
| 1750 | add_post_meta($posts[2], 'foo', 'jjj'); |
|
| 1751 | ||
| 1752 | $q = new WP_Query( |
|
| 1753 | array( |
|
| 1754 | 'fields' => 'ids', |
|
| 1755 | 'meta_query' => array( |
|
| 1756 | 'foo_key' => array( |
|
| 1757 | 'key' => 'foo', |
|
| 1758 | 'compare' => 'EXISTS', |
|
| 1759 | ), |
|
| 1760 | ), |
|
| 1761 | 'orderby' => 'foo_key', |
|
| 1762 | 'order' => 'DESC', |
|
| 1763 | ) |
|
| 1764 | ); |
|
| 1765 | ||
| 1766 | $this->assertEquals(array( $posts[1], $posts[2], $posts[0] ), $q->posts); |
|
| 1767 | } |
|