mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 04:04:35 +00:00
Support date_query by user_registered in WP_User_Query.
Props ChriCo, nacin. Fixes #27283. git-svn-id: https://develop.svn.wordpress.org/trunk@29934 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
58
tests/phpunit/tests/user/dateQuery.php
Normal file
58
tests/phpunit/tests/user/dateQuery.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group user
|
||||
* @group datequery
|
||||
*/
|
||||
class Tests_User_DateQuery extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 27283
|
||||
*/
|
||||
public function test_user_registered() {
|
||||
$u1 = $this->factory->user->create( array(
|
||||
'user_registered' => '2012-02-14 05:05:05',
|
||||
) );
|
||||
$u2 = $this->factory->user->create( array(
|
||||
'user_registered' => '2013-02-14 05:05:05',
|
||||
) );
|
||||
|
||||
$uq = new WP_User_Query( array(
|
||||
'date_query' => array(
|
||||
array(
|
||||
'year' => 2012,
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $u1 ), wp_list_pluck( $uq->results, 'ID' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 27283
|
||||
*/
|
||||
public function test_user_registered_relation_or() {
|
||||
$u1 = $this->factory->user->create( array(
|
||||
'user_registered' => '2012-02-14 05:05:05',
|
||||
) );
|
||||
$u2 = $this->factory->user->create( array(
|
||||
'user_registered' => '2013-02-14 05:05:05',
|
||||
) );
|
||||
$u3 = $this->factory->user->create( array(
|
||||
'user_registered' => '2014-02-14 05:05:05',
|
||||
) );
|
||||
|
||||
$uq = new WP_User_Query( array(
|
||||
'date_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'year' => 2013,
|
||||
),
|
||||
array(
|
||||
'before' => '2012-03-01 00:00:00',
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $u1, $u2 ), wp_list_pluck( $uq->results, 'ID' ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user