mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user