| | 1823 | * @ticket 35512 |
| | 1824 | */ |
| | 1825 | public function test_post_type_any_should_override_other_post_types() { |
| | 1826 | register_post_type( 'post-type-1', array( 'exclude_from_search' => false ) ); |
| | 1827 | register_post_type( 'post-type-2', array( 'exclude_from_search' => false ) ); |
| | 1828 | |
| | 1829 | $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) ); |
| | 1830 | $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) ); |
| | 1831 | |
| | 1832 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| | 1833 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| | 1834 | |
| | 1835 | $q = new WP_Comment_Query(); |
| | 1836 | $found = $q->query( array( |
| | 1837 | 'fields' => 'ids', |
| | 1838 | 'post_type' => array( 'any', 'post-type-1' ), |
| | 1839 | ) ); |
| | 1840 | $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); |
| | 1841 | } |
| | 1842 | |
| | 1843 | /** |
| | 1844 | * @ticket 35512 |
| | 1845 | */ |
| | 1846 | public function test_post_type_any_as_part_of_an_array_of_post_types() { |
| | 1847 | register_post_type( 'post-type-1', array( 'exclude_from_search' => false ) ); |
| | 1848 | register_post_type( 'post-type-2', array( 'exclude_from_search' => false ) ); |
| | 1849 | |
| | 1850 | $p1 = self::factory()->post->create( array( 'post_type' => 'post-type-1' ) ); |
| | 1851 | $p2 = self::factory()->post->create( array( 'post_type' => 'post-type-2' ) ); |
| | 1852 | |
| | 1853 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| | 1854 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| | 1855 | |
| | 1856 | $q = new WP_Comment_Query(); |
| | 1857 | $found = $q->query( array( |
| | 1858 | 'fields' => 'ids', |
| | 1859 | 'post_type' => array( 'any' ), |
| | 1860 | ) ); |
| | 1861 | $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); |
| | 1862 | } |
| | 1863 | |
| | 1864 | /** |
| | 1865 | * @ticket 35512 |
| | 1866 | */ |
| | 1867 | public function test_post_status_any_should_override_other_post_statuses() { |
| | 1868 | $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| | 1869 | $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
| | 1870 | |
| | 1871 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| | 1872 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| | 1873 | |
| | 1874 | $q = new WP_Comment_Query(); |
| | 1875 | $found = $q->query( array( |
| | 1876 | 'fields' => 'ids', |
| | 1877 | 'post_status' => array( 'any', 'draft' ), |
| | 1878 | ) ); |
| | 1879 | $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); |
| | 1880 | } |
| | 1881 | |
| | 1882 | /** |
| | 1883 | * @ticket 35512 |
| | 1884 | */ |
| | 1885 | public function test_post_status_any_as_part_of_an_array_of_post_statuses() { |
| | 1886 | $p1 = self::factory()->post->create( array( 'post_status' => 'publish' ) ); |
| | 1887 | $p2 = self::factory()->post->create( array( 'post_status' => 'draft' ) ); |
| | 1888 | |
| | 1889 | $c1 = self::factory()->comment->create_post_comments( $p1, 1 ); |
| | 1890 | $c2 = self::factory()->comment->create_post_comments( $p2, 1 ); |
| | 1891 | |
| | 1892 | $q = new WP_Comment_Query(); |
| | 1893 | $found = $q->query( array( |
| | 1894 | 'fields' => 'ids', |
| | 1895 | 'post_status' => array( 'any' ), |
| | 1896 | ) ); |
| | 1897 | $this->assertEqualSets( array_merge( $c1, $c2 ), $found ); |
| | 1898 | } |
| | 1899 | |
| | 1900 | /** |