mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
This ensures that not only the array values being compared are equal, but also that their type is the same. These new methods replace most of the existing instances of `assertEqualSets()` and `assertEqualSetsWithIndex()`. Going forward, stricter type checking by using `assertSameSets()` or `assertSameSetsWithIndex()` should generally be preferred, to make the tests more reliable. Follow-up to [48937]. See #38266. git-svn-id: https://develop.svn.wordpress.org/trunk@48939 602fd350-edb4-49c9-b593-d223f7449a82
73 lines
1.3 KiB
PHP
73 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group user
|
|
* @group datequery
|
|
*/
|
|
class Tests_User_DateQuery extends WP_UnitTestCase {
|
|
/**
|
|
* @ticket 27283
|
|
*/
|
|
public function test_user_registered() {
|
|
$u1 = self::factory()->user->create(
|
|
array(
|
|
'user_registered' => '2012-02-14 05:05:05',
|
|
)
|
|
);
|
|
$u2 = self::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->assertSameSets( array( $u1 ), wp_list_pluck( $uq->results, 'ID' ) );
|
|
}
|
|
|
|
/**
|
|
* @ticket 27283
|
|
*/
|
|
public function test_user_registered_relation_or() {
|
|
$u1 = self::factory()->user->create(
|
|
array(
|
|
'user_registered' => '2012-02-14 05:05:05',
|
|
)
|
|
);
|
|
$u2 = self::factory()->user->create(
|
|
array(
|
|
'user_registered' => '2013-02-14 05:05:05',
|
|
)
|
|
);
|
|
$u3 = self::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->assertSameSets( array( $u1, $u2 ), wp_list_pluck( $uq->results, 'ID' ) );
|
|
}
|
|
}
|