WP_Query should not ignore an offset of 0.

Props mazurstas.
Fixes #34060.

git-svn-id: https://develop.svn.wordpress.org/trunk@34697 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-09-29 19:36:16 +00:00
parent 3b7187eade
commit 49063d8e14
2 changed files with 43 additions and 4 deletions

View File

@@ -459,4 +459,42 @@ class Tests_Query extends WP_UnitTestCase {
public function filter_parse_query_to_modify_queried_post_id( $query ) {
$post = get_queried_object();
}
/**
* @ticket 34060
*/
public function test_offset_0_should_override_page() {
$q = new WP_Query( array(
'paged' => 2,
'posts_per_page' => 5,
'offset' => 0,
) );
$this->assertContains( 'LIMIT 0, 5', $q->request );
}
/**
* @ticket 34060
*/
public function test_offset_should_be_ignored_when_not_set() {
$q = new WP_Query( array(
'paged' => 2,
'posts_per_page' => 5,
) );
$this->assertContains( 'LIMIT 5, 5', $q->request );
}
/**
* @ticket 34060
*/
public function test_offset_should_be_ignored_when_passed_a_non_numeric_value() {
$q = new WP_Query( array(
'paged' => 2,
'posts_per_page' => 5,
'offset' => '',
) );
$this->assertContains( 'LIMIT 5, 5', $q->request );
}
}