mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
Introduce 'paged' parameter for WP_User_Query.
This is an alternative to using 'offset', and manually calculating pagination. Note that 'paged' works only in conjunction with 'number', the latter of which provides the per-page value. Props sebastian.pisula. Fixes #25145. git-svn-id: https://develop.svn.wordpress.org/trunk@34531 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -459,7 +459,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
// All values get reset
|
||||
$query->prepare_query( array( 'number' => 8 ) );
|
||||
$this->assertNotEmpty( $query->query_limit );
|
||||
$this->assertEquals( 'LIMIT 8', $query->query_limit );
|
||||
$this->assertEquals( 'LIMIT 0, 8', $query->query_limit );
|
||||
|
||||
// All values get reset
|
||||
$query->prepare_query( array( 'fields' => 'all' ) );
|
||||
@@ -857,4 +857,21 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 25145
|
||||
*/
|
||||
public function test_paged() {
|
||||
$users = $this->factory->user->create_many( 5 );
|
||||
|
||||
$q = new WP_User_Query( array(
|
||||
'number' => 2,
|
||||
'paged' => 2,
|
||||
'orderby' => 'ID',
|
||||
'order' => 'DESC', // Avoid funkiness with user 1.
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEquals( array( $users[2], $users[1] ), $q->results );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user