|
@@ 181-196 (lines=16) @@
|
| 178 |
|
); |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
public function test_orderby_meta_value() |
| 182 |
|
{ |
| 183 |
|
update_user_meta(self::$author_ids[0], 'last_name', 'Jones'); |
| 184 |
|
update_user_meta(self::$author_ids[1], 'last_name', 'Albert'); |
| 185 |
|
update_user_meta(self::$author_ids[2], 'last_name', 'Zorro'); |
| 186 |
|
|
| 187 |
|
$q = new WP_User_Query( |
| 188 |
|
array( |
| 189 |
|
'include' => self::$author_ids, |
| 190 |
|
'meta_key' => 'last_name', |
| 191 |
|
'orderby' => 'meta_value', |
| 192 |
|
'fields' => 'ids' |
| 193 |
|
) |
| 194 |
|
); |
| 195 |
|
|
| 196 |
|
$expected = array( self::$author_ids[3], self::$author_ids[1], self::$author_ids[0], self::$author_ids[2] ); |
| 197 |
|
|
| 198 |
|
$this->assertEquals($expected, $q->get_results()); |
| 199 |
|
} |
|
@@ 204-219 (lines=16) @@
|
| 201 |
|
/** |
| 202 |
|
* @ticket 27887 |
| 203 |
|
*/ |
| 204 |
|
public function test_orderby_meta_value_num() |
| 205 |
|
{ |
| 206 |
|
update_user_meta(self::$author_ids[0], 'user_age', '101'); |
| 207 |
|
update_user_meta(self::$author_ids[1], 'user_age', '20'); |
| 208 |
|
update_user_meta(self::$author_ids[2], 'user_age', '25'); |
| 209 |
|
|
| 210 |
|
$q = new WP_User_Query( |
| 211 |
|
array( |
| 212 |
|
'include' => self::$author_ids, |
| 213 |
|
'meta_key' => 'user_age', |
| 214 |
|
'orderby' => 'meta_value_num', |
| 215 |
|
'fields' => 'ids' |
| 216 |
|
) |
| 217 |
|
); |
| 218 |
|
|
| 219 |
|
$expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ); |
| 220 |
|
|
| 221 |
|
$this->assertEquals($expected, $q->get_results()); |
| 222 |
|
} |
|
@@ 227-242 (lines=16) @@
|
| 224 |
|
/** |
| 225 |
|
* @ticket 31265 |
| 226 |
|
*/ |
| 227 |
|
public function test_orderby_somekey_where_meta_key_is_somekey() |
| 228 |
|
{ |
| 229 |
|
update_user_meta(self::$author_ids[0], 'foo', 'zzz'); |
| 230 |
|
update_user_meta(self::$author_ids[1], 'foo', 'aaa'); |
| 231 |
|
update_user_meta(self::$author_ids[2], 'foo', 'jjj'); |
| 232 |
|
|
| 233 |
|
$q = new WP_User_Query( |
| 234 |
|
array( |
| 235 |
|
'include' => self::$author_ids, |
| 236 |
|
'meta_key' => 'foo', |
| 237 |
|
'orderby' => 'foo', |
| 238 |
|
'fields' => 'ids' |
| 239 |
|
) |
| 240 |
|
); |
| 241 |
|
|
| 242 |
|
$expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ); |
| 243 |
|
|
| 244 |
|
$this->assertEquals($expected, $q->get_results()); |
| 245 |
|
} |