| 166 | |
| 167 | public function test_one_post_per_page_no_split_query() { |
| 168 | $p1 = self::factory()->post->create( |
| 169 | array( |
| 170 | 'post_date' => '2015-04-04 04:04:04', |
| 171 | ) |
| 172 | ); |
| 173 | $p2 = self::factory()->post->create( |
| 174 | array( |
| 175 | 'post_date' => '2014-04-04 04:04:04', |
| 176 | ) |
| 177 | ); |
| 178 | |
| 179 | add_filter( 'split_the_query', array( $this, 'filter_split_the_query_is_false' ) ); |
| 180 | |
| 181 | $found = get_posts( |
| 182 | array( |
| 183 | 'posts_per_page' => 1, |
| 184 | ) |
| 185 | ); |
| 186 | |
| 187 | remove_filter( 'split_the_query', array( $this, 'filter_split_the_query_is_false' ) ); |
| 188 | } |
| 189 | |
| 190 | public function test_two_posts_per_page_split_query() { |
| 191 | $p1 = self::factory()->post->create( |
| 192 | array( |
| 193 | 'post_date' => '2015-04-04 04:04:04', |
| 194 | ) |
| 195 | ); |
| 196 | $p2 = self::factory()->post->create( |
| 197 | array( |
| 198 | 'post_date' => '2014-04-04 04:04:04', |
| 199 | ) |
| 200 | ); |
| 201 | |
| 202 | add_filter( 'split_the_query', array( $this, 'filter_split_the_query_is_true' ) ); |
| 203 | |
| 204 | $found = get_posts( |
| 205 | array( |
| 206 | 'posts_per_page' => 2, |
| 207 | ) |
| 208 | ); |
| 209 | |
| 210 | remove_filter( 'split_the_query', array( $this, 'filter_split_the_query_is_true' ) ); |
| 211 | } |
| 212 | |
| 213 | public function filter_split_the_query_is_false( $split_the_query_default ) { |
| 214 | $this->assertEquals( $split_the_query_default, false ); |
| 215 | } |
| 216 | |
| 217 | public function filter_split_the_query_is_true( $split_the_query_default ) { |
| 218 | $this->assertEquals( $split_the_query_default, true ); |
| 219 | } |