| @@ 853-883 (lines=31) @@ | ||
| 850 | /** |
|
| 851 | * @ticket 30478 |
|
| 852 | */ |
|
| 853 | public function test_orderby_more_than_one_clause_key() |
|
| 854 | { |
|
| 855 | $comments = self::factory()->comment->create_many(3); |
|
| 856 | ||
| 857 | add_comment_meta($comments[0], 'foo', 'jjj'); |
|
| 858 | add_comment_meta($comments[1], 'foo', 'zzz'); |
|
| 859 | add_comment_meta($comments[2], 'foo', 'jjj'); |
|
| 860 | add_comment_meta($comments[0], 'bar', 'aaa'); |
|
| 861 | add_comment_meta($comments[1], 'bar', 'ccc'); |
|
| 862 | add_comment_meta($comments[2], 'bar', 'bbb'); |
|
| 863 | ||
| 864 | $q = new WP_Comment_Query(); |
|
| 865 | $found = $q->query( |
|
| 866 | array( |
|
| 867 | 'fields' => 'ids', |
|
| 868 | 'meta_query' => array( |
|
| 869 | 'foo_key' => array( |
|
| 870 | 'key' => 'foo', |
|
| 871 | 'compare' => 'EXISTS', |
|
| 872 | ), |
|
| 873 | 'bar_key' => array( |
|
| 874 | 'key' => 'bar', |
|
| 875 | 'compare' => 'EXISTS', |
|
| 876 | ), |
|
| 877 | ), |
|
| 878 | 'orderby' => array( |
|
| 879 | 'foo_key' => 'asc', |
|
| 880 | 'bar_key' => 'desc', |
|
| 881 | ), |
|
| 882 | ) |
|
| 883 | ); |
|
| 884 | ||
| 885 | $this->assertEquals(array( $comments[2], $comments[0], $comments[1] ), $found); |
|
| 886 | } |
|
| @@ 1816-1845 (lines=30) @@ | ||
| 1813 | /** |
|
| 1814 | * @ticket 31045 |
|
| 1815 | */ |
|
| 1816 | public function test_orderby_more_than_one_clause_key() |
|
| 1817 | { |
|
| 1818 | $posts = self::factory()->post->create_many(3); |
|
| 1819 | ||
| 1820 | add_post_meta($posts[0], 'foo', 'jjj'); |
|
| 1821 | add_post_meta($posts[1], 'foo', 'zzz'); |
|
| 1822 | add_post_meta($posts[2], 'foo', 'jjj'); |
|
| 1823 | add_post_meta($posts[0], 'bar', 'aaa'); |
|
| 1824 | add_post_meta($posts[1], 'bar', 'ccc'); |
|
| 1825 | add_post_meta($posts[2], 'bar', 'bbb'); |
|
| 1826 | ||
| 1827 | $q = new WP_Query( |
|
| 1828 | array( |
|
| 1829 | 'fields' => 'ids', |
|
| 1830 | 'meta_query' => array( |
|
| 1831 | 'foo_key' => array( |
|
| 1832 | 'key' => 'foo', |
|
| 1833 | 'compare' => 'EXISTS', |
|
| 1834 | ), |
|
| 1835 | 'bar_key' => array( |
|
| 1836 | 'key' => 'bar', |
|
| 1837 | 'compare' => 'EXISTS', |
|
| 1838 | ), |
|
| 1839 | ), |
|
| 1840 | 'orderby' => array( |
|
| 1841 | 'foo_key' => 'asc', |
|
| 1842 | 'bar_key' => 'desc', |
|
| 1843 | ), |
|
| 1844 | ) |
|
| 1845 | ); |
|
| 1846 | ||
| 1847 | $this->assertEquals(array( $posts[2], $posts[0], $posts[1] ), $q->posts); |
|
| 1848 | } |
|