| | 2081 | /** |
| | 2082 | * @ticket 35935 |
| | 2083 | */ |
| | 2084 | public function test_hierarchical_offset_0_with_number_greater_than_total_available_count() { |
| | 2085 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
| | 2086 | |
| | 2087 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| | 2088 | |
| | 2089 | $found = get_terms( 'wptests_tax', array( |
| | 2090 | 'number' => 3, |
| | 2091 | 'offset' => 0, |
| | 2092 | 'hide_empty' => false, |
| | 2093 | 'fields' => 'ids', |
| | 2094 | ) ); |
| | 2095 | $this->assertEqualSets( $terms, $found ); |
| | 2096 | } |
| | 2097 | |
| | 2098 | /** |
| | 2099 | * @ticket 35935 |
| | 2100 | */ |
| | 2101 | public function test_hierarchical_offset_plus_number() { |
| | 2102 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
| | 2103 | |
| | 2104 | $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); |
| | 2105 | |
| | 2106 | $found = get_terms( 'wptests_tax', array( |
| | 2107 | 'number' => 1, |
| | 2108 | 'offset' => 1, |
| | 2109 | 'hide_empty' => false, |
| | 2110 | 'fields' => 'ids', |
| | 2111 | 'orderby' => 'term_id', |
| | 2112 | 'order' => 'ASC', |
| | 2113 | ) ); |
| | 2114 | $this->assertEqualSets( array( $terms[1] ), $found ); |
| | 2115 | } |
| | 2116 | |
| | 2117 | /** |
| | 2118 | * @ticket 35935 |
| | 2119 | */ |
| | 2120 | public function test_hierarchical_offset_plus_number_exceeds_available_count() { |
| | 2121 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
| | 2122 | |
| | 2123 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| | 2124 | |
| | 2125 | $found = get_terms( 'wptests_tax', array( |
| | 2126 | 'number' => 2, |
| | 2127 | 'offset' => 1, |
| | 2128 | 'hide_empty' => false, |
| | 2129 | 'fields' => 'ids', |
| | 2130 | 'orderby' => 'term_id', |
| | 2131 | 'order' => 'ASC', |
| | 2132 | ) ); |
| | 2133 | $this->assertEqualSets( array( $terms[1] ), $found ); |
| | 2134 | } |
| | 2135 | |
| | 2136 | /** |
| | 2137 | * @ticket 35935 |
| | 2138 | */ |
| | 2139 | public function test_hierarchical_offset_exceeds_available_count() { |
| | 2140 | register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); |
| | 2141 | |
| | 2142 | $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); |
| | 2143 | |
| | 2144 | $found = get_terms( 'wptests_tax', array( |
| | 2145 | 'number' => 100, |
| | 2146 | 'offset' => 3, |
| | 2147 | 'hide_empty' => false, |
| | 2148 | 'fields' => 'ids', |
| | 2149 | 'orderby' => 'term_id', |
| | 2150 | 'order' => 'ASC', |
| | 2151 | ) ); |
| | 2152 | $this->assertEqualSets( array(), $found ); |
| | 2153 | } |
| | 2154 | |