Changeset 42343 for trunk/tests/phpunit/tests/user/query.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/query.php
r40982 r42343 15 15 16 16 public static function wpSetUpBeforeClass( $factory ) { 17 self::$author_ids = $factory->user->create_many( 4, array( 18 'role' => 'author' 19 ) ); 20 21 self::$sub_ids = $factory->user->create_many( 2, array( 22 'role' => 'subscriber', 23 ) ); 24 25 self::$editor_ids = $factory->user->create_many( 3, array( 26 'role' => 'editor', 27 ) ); 28 29 self::$contrib_id = $factory->user->create( array( 30 'role' => 'contributor', 31 ) ); 32 33 self::$admin_ids = $factory->user->create_many( 2, array( 34 'role' => 'administrator', 35 ) ); 17 self::$author_ids = $factory->user->create_many( 18 4, array( 19 'role' => 'author', 20 ) 21 ); 22 23 self::$sub_ids = $factory->user->create_many( 24 2, array( 25 'role' => 'subscriber', 26 ) 27 ); 28 29 self::$editor_ids = $factory->user->create_many( 30 3, array( 31 'role' => 'editor', 32 ) 33 ); 34 35 self::$contrib_id = $factory->user->create( 36 array( 37 'role' => 'contributor', 38 ) 39 ); 40 41 self::$admin_ids = $factory->user->create_many( 42 2, array( 43 'role' => 'administrator', 44 ) 45 ); 36 46 } 37 47 … … 55 65 56 66 public function test_include_single() { 57 $q = new WP_User_Query( array( 58 'fields' => '', 59 'include' => self::$author_ids[0], 60 ) ); 67 $q = new WP_User_Query( 68 array( 69 'fields' => '', 70 'include' => self::$author_ids[0], 71 ) 72 ); 61 73 $ids = $q->get_results(); 62 74 … … 65 77 66 78 public function test_include_comma_separated() { 67 $q = new WP_User_Query( array( 68 'fields' => '', 69 'include' => self::$author_ids[0] . ', ' . self::$author_ids[2], 70 ) ); 79 $q = new WP_User_Query( 80 array( 81 'fields' => '', 82 'include' => self::$author_ids[0] . ', ' . self::$author_ids[2], 83 ) 84 ); 71 85 $ids = $q->get_results(); 72 86 … … 75 89 76 90 public function test_include_array() { 77 $q = new WP_User_Query( array( 78 'fields' => '', 79 'include' => array( self::$author_ids[0], self::$author_ids[2] ), 80 ) ); 91 $q = new WP_User_Query( 92 array( 93 'fields' => '', 94 'include' => array( self::$author_ids[0], self::$author_ids[2] ), 95 ) 96 ); 81 97 $ids = $q->get_results(); 82 98 … … 85 101 86 102 public function test_include_array_bad_values() { 87 $q = new WP_User_Query( array( 88 'fields' => '', 89 'include' => array( self::$author_ids[0], 'foo', self::$author_ids[2] ), 90 ) ); 103 $q = new WP_User_Query( 104 array( 105 'fields' => '', 106 'include' => array( self::$author_ids[0], 'foo', self::$author_ids[2] ), 107 ) 108 ); 91 109 $ids = $q->get_results(); 92 110 … … 95 113 96 114 public function test_exclude() { 97 $q = new WP_User_Query( array( 98 'fields' => '', 99 'exclude' => self::$author_ids[1], 100 ) ); 115 $q = new WP_User_Query( 116 array( 117 'fields' => '', 118 'exclude' => self::$author_ids[1], 119 ) 120 ); 101 121 102 122 $ids = $q->get_results(); … … 117 137 } 118 138 119 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'fields' => 'all_with_meta' ) ); 139 $users = new WP_User_Query( 140 array( 141 'blog_id' => get_current_blog_id(), 142 'fields' => 'all_with_meta', 143 ) 144 ); 120 145 $users = $users->get_results(); 121 146 $this->assertEquals( 13, count( $users ) ); … … 129 154 */ 130 155 public function test_get_total_is_int() { 131 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) );156 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) ); 132 157 $total_users = $users->get_total(); 133 158 … … 139 164 */ 140 165 public function test_orderby_should_convert_non_prefixed_keys( $short_key, $full_key ) { 141 $q = new WP_User_Query( array( 142 'orderby' => $short_key, 143 ) ); 166 $q = new WP_User_Query( 167 array( 168 'orderby' => $short_key, 169 ) 170 ); 144 171 145 172 $this->assertContains( "ORDER BY $full_key", $q->query_orderby ); … … 161 188 update_user_meta( self::$author_ids[2], 'last_name', 'Zorro' ); 162 189 163 $q = new WP_User_Query( array( 164 'include' => self::$author_ids, 165 'meta_key' => 'last_name', 166 'orderby' => 'meta_value', 167 'fields' => 'ids' 168 ) ); 190 $q = new WP_User_Query( 191 array( 192 'include' => self::$author_ids, 193 'meta_key' => 'last_name', 194 'orderby' => 'meta_value', 195 'fields' => 'ids', 196 ) 197 ); 169 198 170 199 $expected = array( self::$author_ids[3], self::$author_ids[1], self::$author_ids[0], self::$author_ids[2] ); … … 181 210 update_user_meta( self::$author_ids[2], 'user_age', '25' ); 182 211 183 $q = new WP_User_Query( array( 184 'include' => self::$author_ids, 185 'meta_key' => 'user_age', 186 'orderby' => 'meta_value_num', 187 'fields' => 'ids' 188 ) ); 212 $q = new WP_User_Query( 213 array( 214 'include' => self::$author_ids, 215 'meta_key' => 'user_age', 216 'orderby' => 'meta_value_num', 217 'fields' => 'ids', 218 ) 219 ); 189 220 190 221 $expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ); … … 201 232 update_user_meta( self::$author_ids[2], 'foo', 'jjj' ); 202 233 203 $q = new WP_User_Query( array( 204 'include' => self::$author_ids, 205 'meta_key' => 'foo', 206 'orderby' => 'foo', 207 'fields' => 'ids' 208 ) ); 234 $q = new WP_User_Query( 235 array( 236 'include' => self::$author_ids, 237 'meta_key' => 'foo', 238 'orderby' => 'foo', 239 'fields' => 'ids', 240 ) 241 ); 209 242 210 243 $expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ); … … 221 254 add_user_meta( self::$author_ids[2], 'foo', 'jjj' ); 222 255 223 $q = new WP_User_Query( array( 224 'fields' => 'ids', 225 'meta_query' => array( 226 'foo_key' => array( 227 'key' => 'foo', 228 'compare' => 'EXISTS', 256 $q = new WP_User_Query( 257 array( 258 'fields' => 'ids', 259 'meta_query' => array( 260 'foo_key' => array( 261 'key' => 'foo', 262 'compare' => 'EXISTS', 263 ), 229 264 ), 230 ),231 'orderby' => 'foo_key',232 'order' => 'DESC',233 ) );265 'orderby' => 'foo_key', 266 'order' => 'DESC', 267 ) 268 ); 234 269 235 270 $this->assertEquals( array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ), $q->results ); … … 240 275 */ 241 276 public function test_orderby_clause_key_as_secondary_sort() { 242 $u1 = self::factory()->user->create( array( 243 'user_registered' => '2015-01-28 03:00:00', 244 ) ); 245 $u2 = self::factory()->user->create( array( 246 'user_registered' => '2015-01-28 05:00:00', 247 ) ); 248 $u3 = self::factory()->user->create( array( 249 'user_registered' => '2015-01-28 03:00:00', 250 ) ); 277 $u1 = self::factory()->user->create( 278 array( 279 'user_registered' => '2015-01-28 03:00:00', 280 ) 281 ); 282 $u2 = self::factory()->user->create( 283 array( 284 'user_registered' => '2015-01-28 05:00:00', 285 ) 286 ); 287 $u3 = self::factory()->user->create( 288 array( 289 'user_registered' => '2015-01-28 03:00:00', 290 ) 291 ); 251 292 252 293 add_user_meta( $u1, 'foo', 'jjj' ); … … 254 295 add_user_meta( $u3, 'foo', 'aaa' ); 255 296 256 $q = new WP_User_Query( array( 257 'fields' => 'ids', 258 'meta_query' => array( 259 'foo_key' => array( 260 'key' => 'foo', 261 'compare' => 'EXISTS', 297 $q = new WP_User_Query( 298 array( 299 'fields' => 'ids', 300 'meta_query' => array( 301 'foo_key' => array( 302 'key' => 'foo', 303 'compare' => 'EXISTS', 304 ), 262 305 ), 263 ),264 'orderby' => array(265 'comment_date'=> 'asc',266 'foo_key' => 'asc',267 ) ,268 ) );306 'orderby' => array( 307 'comment_date' => 'asc', 308 'foo_key' => 'asc', 309 ), 310 ) 311 ); 269 312 270 313 $this->assertEquals( array( $u3, $u1, $u2 ), $q->results ); … … 282 325 add_user_meta( self::$author_ids[2], 'bar', 'bbb' ); 283 326 284 $q = new WP_User_Query( array( 285 'fields' => 'ids', 286 'meta_query' => array( 287 'foo_key' => array( 288 'key' => 'foo', 289 'compare' => 'EXISTS', 327 $q = new WP_User_Query( 328 array( 329 'fields' => 'ids', 330 'meta_query' => array( 331 'foo_key' => array( 332 'key' => 'foo', 333 'compare' => 'EXISTS', 334 ), 335 'bar_key' => array( 336 'key' => 'bar', 337 'compare' => 'EXISTS', 338 ), 290 339 ), 291 ' bar_key'=> array(292 ' key' => 'bar',293 ' compare' => 'EXISTS',340 'orderby' => array( 341 'foo_key' => 'asc', 342 'bar_key' => 'desc', 294 343 ), 295 ), 296 'orderby' => array( 297 'foo_key' => 'asc', 298 'bar_key' => 'desc', 299 ), 300 ) ); 344 ) 345 ); 301 346 302 347 $this->assertEquals( array( self::$author_ids[2], self::$author_ids[0], self::$author_ids[1] ), $q->results ); … … 307 352 */ 308 353 public function test_orderby_include_with_empty_include() { 309 $q = new WP_User_Query( array( 310 'orderby' => 'include', 311 ) ); 354 $q = new WP_User_Query( 355 array( 356 'orderby' => 'include', 357 ) 358 ); 312 359 313 360 $this->assertContains( 'ORDER BY user_login', $q->query_orderby ); … … 320 367 global $wpdb; 321 368 322 $q = new WP_User_Query( array( 323 'orderby' => 'include', 324 'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[3] ), 325 'fields' => '', 326 ) ); 369 $q = new WP_User_Query( 370 array( 371 'orderby' => 'include', 372 'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[3] ), 373 'fields' => '', 374 ) 375 ); 327 376 328 377 $expected_orderby = 'ORDER BY FIELD( ' . $wpdb->users . '.ID, ' . self::$author_ids[1] . ',' . self::$author_ids[0] . ',' . self::$author_ids[3] . ' )'; … … 339 388 global $wpdb; 340 389 341 $q = new WP_User_Query( array( 342 'orderby' => 'include', 343 'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[1], self::$author_ids[3] ), 344 'fields' => '', 345 ) ); 390 $q = new WP_User_Query( 391 array( 392 'orderby' => 'include', 393 'include' => array( self::$author_ids[1], self::$author_ids[0], self::$author_ids[1], self::$author_ids[3] ), 394 'fields' => '', 395 ) 396 ); 346 397 347 398 $expected_orderby = 'ORDER BY FIELD( ' . $wpdb->users . '.ID, ' . self::$author_ids[1] . ',' . self::$author_ids[0] . ',' . self::$author_ids[3] . ' )'; … … 356 407 */ 357 408 public function test_orderby_space_separated() { 358 $q = new WP_User_Query( array( 359 'orderby' => 'login nicename', 360 'order' => 'ASC', 361 ) ); 362 363 $this->assertContains( "ORDER BY user_login ASC, user_nicename ASC", $q->query_orderby ); 409 $q = new WP_User_Query( 410 array( 411 'orderby' => 'login nicename', 412 'order' => 'ASC', 413 ) 414 ); 415 416 $this->assertContains( 'ORDER BY user_login ASC, user_nicename ASC', $q->query_orderby ); 364 417 } 365 418 … … 368 421 */ 369 422 public function test_orderby_flat_array() { 370 $q = new WP_User_Query( array( 371 'orderby' => array( 'login', 'nicename' ), 372 ) ); 373 374 $this->assertContains( "ORDER BY user_login ASC, user_nicename ASC", $q->query_orderby ); 423 $q = new WP_User_Query( 424 array( 425 'orderby' => array( 'login', 'nicename' ), 426 ) 427 ); 428 429 $this->assertContains( 'ORDER BY user_login ASC, user_nicename ASC', $q->query_orderby ); 375 430 } 376 431 … … 379 434 */ 380 435 public function test_orderby_array_contains_invalid_item() { 381 $q = new WP_User_Query( array( 382 'orderby' => array( 'login', 'foo', 'nicename' ), 383 ) ); 384 385 $this->assertContains( "ORDER BY user_login ASC, user_nicename ASC", $q->query_orderby ); 436 $q = new WP_User_Query( 437 array( 438 'orderby' => array( 'login', 'foo', 'nicename' ), 439 ) 440 ); 441 442 $this->assertContains( 'ORDER BY user_login ASC, user_nicename ASC', $q->query_orderby ); 386 443 } 387 444 … … 390 447 */ 391 448 public function test_orderby_array_contains_all_invalid_items() { 392 $q = new WP_User_Query( array( 393 'orderby' => array( 'foo', 'bar', 'baz' ), 394 ) ); 395 396 $this->assertContains( "ORDER BY user_login", $q->query_orderby ); 449 $q = new WP_User_Query( 450 array( 451 'orderby' => array( 'foo', 'bar', 'baz' ), 452 ) 453 ); 454 455 $this->assertContains( 'ORDER BY user_login', $q->query_orderby ); 397 456 } 398 457 … … 401 460 */ 402 461 public function test_orderby_array() { 403 $q = new WP_User_Query( array( 404 'orderby' => array( 405 'login' => 'DESC', 406 'nicename' => 'ASC', 407 'email' => 'DESC', 408 ), 409 ) ); 410 411 $this->assertContains( "ORDER BY user_login DESC, user_nicename ASC, user_email DESC", $q->query_orderby ); 462 $q = new WP_User_Query( 463 array( 464 'orderby' => array( 465 'login' => 'DESC', 466 'nicename' => 'ASC', 467 'email' => 'DESC', 468 ), 469 ) 470 ); 471 472 $this->assertContains( 'ORDER BY user_login DESC, user_nicename ASC, user_email DESC', $q->query_orderby ); 412 473 } 413 474 … … 416 477 */ 417 478 public function test_orderby_array_should_discard_invalid_columns() { 418 $q = new WP_User_Query( array( 419 'orderby' => array( 420 'login' => 'DESC', 421 'foo' => 'ASC', 422 'email' => 'ASC', 423 ), 424 ) ); 425 426 $this->assertContains( "ORDER BY user_login DESC, user_email ASC", $q->query_orderby ); 479 $q = new WP_User_Query( 480 array( 481 'orderby' => array( 482 'login' => 'DESC', 483 'foo' => 'ASC', 484 'email' => 'ASC', 485 ), 486 ) 487 ); 488 489 $this->assertContains( 'ORDER BY user_login DESC, user_email ASC', $q->query_orderby ); 427 490 } 428 491 … … 436 499 $this->assertEquals( 13, count( $users ) ); 437 500 438 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'number' => 10 ) ); 501 $users = new WP_User_Query( 502 array( 503 'blog_id' => get_current_blog_id(), 504 'number' => 10, 505 ) 506 ); 439 507 $users = $users->get_results(); 440 508 $this->assertEquals( 10, count( $users ) ); 441 509 442 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'number' => 2 ) ); 510 $users = new WP_User_Query( 511 array( 512 'blog_id' => get_current_blog_id(), 513 'number' => 2, 514 ) 515 ); 443 516 $users = $users->get_results(); 444 517 $this->assertEquals( 2, count( $users ) ); 445 518 446 $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id(), 'number' => -1 ) ); 519 $users = new WP_User_Query( 520 array( 521 'blog_id' => get_current_blog_id(), 522 'number' => -1, 523 ) 524 ); 447 525 $users = $users->get_results(); 448 526 $this->assertEquals( 13, count( $users ) ); … … 491 569 492 570 public function test_meta_vars_should_be_converted_to_meta_query() { 493 $q = new WP_User_Query( array( 494 'meta_key' => 'foo', 495 'meta_value' => '5', 496 'meta_compare' => '>', 497 'meta_type' => 'SIGNED', 498 ) ); 571 $q = new WP_User_Query( 572 array( 573 'meta_key' => 'foo', 574 'meta_value' => '5', 575 'meta_compare' => '>', 576 'meta_type' => 'SIGNED', 577 ) 578 ); 499 579 500 580 // Multisite adds a 'blog_id' clause, so we have to find the 'foo' clause. … … 520 600 521 601 // Users with foo = bar or baz restricted to the author role. 522 $query = new WP_User_Query( array( 523 'fields' => '', 524 'role' => 'author', 525 'meta_query' => array( 526 'relation' => 'OR', 527 array( 528 'key' => 'foo', 529 'value' => 'bar', 602 $query = new WP_User_Query( 603 array( 604 'fields' => '', 605 'role' => 'author', 606 'meta_query' => array( 607 'relation' => 'OR', 608 array( 609 'key' => 'foo', 610 'value' => 'bar', 611 ), 612 array( 613 'key' => 'foo', 614 'value' => 'baz', 615 ), 530 616 ), 531 array( 532 'key' => 'foo', 533 'value' => 'baz', 534 ), 535 ), 536 ) ); 617 ) 618 ); 537 619 538 620 $this->assertEquals( array( self::$author_ids[0], self::$author_ids[1] ), $query->get_results() ); … … 540 622 541 623 public function test_roles_and_caps_should_be_populated_for_default_value_of_blog_id() { 542 $query = new WP_User_Query( array( 543 'include' => self::$author_ids[0], 544 ) ); 624 $query = new WP_User_Query( 625 array( 626 'include' => self::$author_ids[0], 627 ) 628 ); 545 629 546 630 $found = $query->get_results(); … … 556 640 */ 557 641 public function test_roles_and_caps_should_be_populated_for_explicit_value_of_blog_id_on_nonms() { 558 $query = new WP_User_Query( array( 559 'include' => self::$author_ids[0], 560 'blog_id' => get_current_blog_id(), 561 ) ); 642 $query = new WP_User_Query( 643 array( 644 'include' => self::$author_ids[0], 645 'blog_id' => get_current_blog_id(), 646 ) 647 ); 562 648 563 649 $found = $query->get_results(); … … 573 659 */ 574 660 public function test_roles_and_caps_should_be_populated_for_explicit_value_of_current_blog_id_on_ms() { 575 $query = new WP_User_Query( array( 576 'include' => self::$author_ids[0], 577 'blog_id' => get_current_blog_id(), 578 ) ); 661 $query = new WP_User_Query( 662 array( 663 'include' => self::$author_ids[0], 664 'blog_id' => get_current_blog_id(), 665 ) 666 ); 579 667 580 668 $found = $query->get_results(); … … 594 682 add_user_to_blog( $b, self::$author_ids[0], 'author' ); 595 683 596 $query = new WP_User_Query( array( 597 'include' => self::$author_ids[0], 598 'blog_id' => $b, 599 'fields' => 'all_with_meta', 600 ) ); 684 $query = new WP_User_Query( 685 array( 686 'include' => self::$author_ids[0], 687 'blog_id' => $b, 688 'fields' => 'all_with_meta', 689 ) 690 ); 601 691 602 692 $found = $query->get_results(); … … 616 706 add_user_to_blog( $b, self::$author_ids[0], 'author' ); 617 707 618 $query = new WP_User_Query( array( 619 'fields' => 'all', 620 'include' => self::$author_ids[0], 621 'blog_id' => $b, 622 ) ); 708 $query = new WP_User_Query( 709 array( 710 'fields' => 'all', 711 'include' => self::$author_ids[0], 712 'blog_id' => $b, 713 ) 714 ); 623 715 624 716 $found = $query->get_results(); … … 641 733 add_user_to_blog( $b, self::$author_ids[2], 'editor' ); 642 734 643 $q = new WP_User_Query( array( 644 'who' => 'authors', 645 'blog_id' => $b, 646 ) ); 735 $q = new WP_User_Query( 736 array( 737 'who' => 'authors', 738 'blog_id' => $b, 739 ) 740 ); 647 741 648 742 $found = wp_list_pluck( $q->get_results(), 'ID' ); … … 667 761 add_user_meta( self::$author_ids[2], 'foo', 'baz' ); 668 762 669 $q = new WP_User_Query( array( 670 'who' => 'authors', 671 'blog_id' => $b, 672 'meta_query' => array( 673 array( 674 'key' => 'foo', 675 'value' => 'bar', 676 ) 677 ), 678 ) ); 763 $q = new WP_User_Query( 764 array( 765 'who' => 'authors', 766 'blog_id' => $b, 767 'meta_query' => array( 768 array( 769 'key' => 'foo', 770 'value' => 'bar', 771 ), 772 ), 773 ) 774 ); 679 775 680 776 $found = wp_list_pluck( $q->get_results(), 'ID' ); … … 699 795 add_user_meta( self::$author_ids[2], 'foo', 'baz' ); 700 796 701 $q = new WP_User_Query( array( 702 'who' => 'authors', 703 'blog_id' => $b, 704 'meta_key' => 'foo', 705 'meta_value' => 'bar', 706 ) ); 797 $q = new WP_User_Query( 798 array( 799 'who' => 'authors', 800 'blog_id' => $b, 801 'meta_key' => 'foo', 802 'meta_value' => 'bar', 803 ) 804 ); 707 805 708 806 $found = wp_list_pluck( $q->get_results(), 'ID' ); … … 720 818 register_post_type( 'wptests_pt_private', array( 'public' => false ) ); 721 819 722 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); 723 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); 724 725 $q = new WP_User_Query( array( 726 'has_published_posts' => true, 727 ) ); 728 729 $found = wp_list_pluck( $q->get_results(), 'ID' ); 820 self::factory()->post->create( 821 array( 822 'post_author' => self::$author_ids[0], 823 'post_status' => 'publish', 824 'post_type' => 'wptests_pt_public', 825 ) 826 ); 827 self::factory()->post->create( 828 array( 829 'post_author' => self::$author_ids[1], 830 'post_status' => 'publish', 831 'post_type' => 'wptests_pt_private', 832 ) 833 ); 834 835 $q = new WP_User_Query( 836 array( 837 'has_published_posts' => true, 838 ) 839 ); 840 841 $found = wp_list_pluck( $q->get_results(), 'ID' ); 730 842 $expected = array( self::$author_ids[0] ); 731 843 … … 740 852 register_post_type( 'wptests_pt_private', array( 'public' => false ) ); 741 853 742 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'wptests_pt_public' ) ); 743 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'wptests_pt_private' ) ); 744 self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); 745 746 $q = new WP_User_Query( array( 747 'has_published_posts' => array( 'wptests_pt_private', 'post' ), 748 ) ); 749 750 $found = wp_list_pluck( $q->get_results(), 'ID' ); 854 self::factory()->post->create( 855 array( 856 'post_author' => self::$author_ids[0], 857 'post_status' => 'publish', 858 'post_type' => 'wptests_pt_public', 859 ) 860 ); 861 self::factory()->post->create( 862 array( 863 'post_author' => self::$author_ids[1], 864 'post_status' => 'publish', 865 'post_type' => 'wptests_pt_private', 866 ) 867 ); 868 self::factory()->post->create( 869 array( 870 'post_author' => self::$author_ids[2], 871 'post_status' => 'publish', 872 'post_type' => 'post', 873 ) 874 ); 875 876 $q = new WP_User_Query( 877 array( 878 'has_published_posts' => array( 'wptests_pt_private', 'post' ), 879 ) 880 ); 881 882 $found = wp_list_pluck( $q->get_results(), 'ID' ); 751 883 $expected = array( self::$author_ids[1], self::$author_ids[2] ); 752 884 … … 761 893 register_post_type( 'wptests_pt_private', array( 'public' => false ) ); 762 894 763 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'draft', 'post_type' => 'wptests_pt_public' ) ); 764 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'inherit', 'post_type' => 'wptests_pt_private' ) ); 765 self::factory()->post->create( array( 'post_author' => self::$author_ids[2], 'post_status' => 'publish', 'post_type' => 'post' ) ); 766 767 $q = new WP_User_Query( array( 768 'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ), 769 ) ); 770 771 $found = wp_list_pluck( $q->get_results(), 'ID' ); 895 self::factory()->post->create( 896 array( 897 'post_author' => self::$author_ids[0], 898 'post_status' => 'draft', 899 'post_type' => 'wptests_pt_public', 900 ) 901 ); 902 self::factory()->post->create( 903 array( 904 'post_author' => self::$author_ids[1], 905 'post_status' => 'inherit', 906 'post_type' => 'wptests_pt_private', 907 ) 908 ); 909 self::factory()->post->create( 910 array( 911 'post_author' => self::$author_ids[2], 912 'post_status' => 'publish', 913 'post_type' => 'post', 914 ) 915 ); 916 917 $q = new WP_User_Query( 918 array( 919 'has_published_posts' => array( 'wptests_pt_public', 'wptests_pt_private', 'post' ), 920 ) 921 ); 922 923 $found = wp_list_pluck( $q->get_results(), 'ID' ); 772 924 $expected = array( self::$author_ids[2] ); 773 925 … … 788 940 789 941 switch_to_blog( $blogs[0] ); 790 self::factory()->post->create( array( 'post_author' => self::$author_ids[0], 'post_status' => 'publish', 'post_type' => 'post' ) ); 942 self::factory()->post->create( 943 array( 944 'post_author' => self::$author_ids[0], 945 'post_status' => 'publish', 946 'post_type' => 'post', 947 ) 948 ); 791 949 restore_current_blog(); 792 950 793 951 switch_to_blog( $blogs[1] ); 794 self::factory()->post->create( array( 'post_author' => self::$author_ids[1], 'post_status' => 'publish', 'post_type' => 'post' ) ); 952 self::factory()->post->create( 953 array( 954 'post_author' => self::$author_ids[1], 955 'post_status' => 'publish', 956 'post_type' => 'post', 957 ) 958 ); 795 959 restore_current_blog(); 796 960 797 $q = new WP_User_Query( array( 798 'has_published_posts' => array( 'post' ), 799 'blog_id' => $blogs[1], 800 ) ); 801 802 $found = wp_list_pluck( $q->get_results(), 'ID' ); 961 $q = new WP_User_Query( 962 array( 963 'has_published_posts' => array( 'post' ), 964 'blog_id' => $blogs[1], 965 ) 966 ); 967 968 $found = wp_list_pluck( $q->get_results(), 'ID' ); 803 969 $expected = array( self::$author_ids[1] ); 804 970 … … 814 980 add_user_meta( self::$author_ids[0], 'foo2', 'bar2' ); 815 981 816 $q = new WP_User_Query( array( 817 'meta_query' => array( 818 'relation' => 'OR', 819 array( 820 'key' => 'foo', 821 'value' => 'bar', 982 $q = new WP_User_Query( 983 array( 984 'meta_query' => array( 985 'relation' => 'OR', 986 array( 987 'key' => 'foo', 988 'value' => 'bar', 989 ), 990 array( 991 'key' => 'foo2', 992 'value' => 'bar2', 993 ), 822 994 ), 823 array( 824 'key' => 'foo2', 825 'value' => 'bar2', 826 ), 827 ), 828 ) ); 829 830 $found = wp_list_pluck( $q->get_results(), 'ID' ); 995 ) 996 ); 997 998 $found = wp_list_pluck( $q->get_results(), 'ID' ); 831 999 $expected = array( self::$author_ids[0], self::$author_ids[1] ); 832 1000 … … 843 1011 add_user_meta( self::$author_ids[1], 'foo3', 'bar3' ); 844 1012 845 $q = new WP_User_Query( array( 846 'meta_query' => array( 847 'relation' => 'AND', 848 array( 849 'key' => 'foo', 850 'value' => 'bar', 851 ), 852 array( 853 'relation' => 'OR', 1013 $q = new WP_User_Query( 1014 array( 1015 'meta_query' => array( 1016 'relation' => 'AND', 854 1017 array( 855 'key' => 'foo',1018 'key' => 'foo', 856 1019 'value' => 'bar', 857 1020 ), 858 1021 array( 859 'key' => 'foo2', 860 'value' => 'bar2', 1022 'relation' => 'OR', 1023 array( 1024 'key' => 'foo', 1025 'value' => 'bar', 1026 ), 1027 array( 1028 'key' => 'foo2', 1029 'value' => 'bar2', 1030 ), 861 1031 ), 862 1032 ), 863 ) ,864 ) );865 866 $found = wp_list_pluck( $q->get_results(), 'ID' );1033 ) 1034 ); 1035 1036 $found = wp_list_pluck( $q->get_results(), 'ID' ); 867 1037 $expected = array( self::$author_ids[0], self::$author_ids[1] ); 868 1038 … … 874 1044 */ 875 1045 public function test_nicename_returns_user_with_nicename() { 876 wp_update_user( array( 877 'ID' => self::$author_ids[0], 878 'user_nicename' => 'peter' 879 ) ); 880 881 $q = new WP_User_Query( array ( 882 'nicename' => 'peter' 883 ) ); 884 885 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1046 wp_update_user( 1047 array( 1048 'ID' => self::$author_ids[0], 1049 'user_nicename' => 'peter', 1050 ) 1051 ); 1052 1053 $q = new WP_User_Query( 1054 array( 1055 'nicename' => 'peter', 1056 ) 1057 ); 1058 1059 $found = wp_list_pluck( $q->get_results(), 'ID' ); 886 1060 $expected = array( self::$author_ids[0] ); 887 1061 888 $this->assertContains( "AND user_nicename = 'peter'", $q->query_where );889 $this->assertEqualSets( $expected, $found );1062 $this->assertContains( "AND user_nicename = 'peter'", $q->query_where ); 1063 $this->assertEqualSets( $expected, $found ); 890 1064 } 891 1065 … … 894 1068 */ 895 1069 public function test_nicename__in_returns_users_with_included_nicenames() { 896 wp_update_user( array( 897 'ID' => self::$author_ids[0], 898 'user_nicename' => 'peter' 899 ) ); 900 901 wp_update_user( array( 902 'ID' => self::$author_ids[1], 903 'user_nicename' => 'paul' 904 ) ); 905 906 wp_update_user( array( 907 'ID' => self::$author_ids[2], 908 'user_nicename' => 'mary' 909 ) ); 910 911 $q = new WP_User_Query( array ( 912 'nicename__in' => array( 'peter', 'paul', 'mary' ) 913 ) ); 914 915 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1070 wp_update_user( 1071 array( 1072 'ID' => self::$author_ids[0], 1073 'user_nicename' => 'peter', 1074 ) 1075 ); 1076 1077 wp_update_user( 1078 array( 1079 'ID' => self::$author_ids[1], 1080 'user_nicename' => 'paul', 1081 ) 1082 ); 1083 1084 wp_update_user( 1085 array( 1086 'ID' => self::$author_ids[2], 1087 'user_nicename' => 'mary', 1088 ) 1089 ); 1090 1091 $q = new WP_User_Query( 1092 array( 1093 'nicename__in' => array( 'peter', 'paul', 'mary' ), 1094 ) 1095 ); 1096 1097 $found = wp_list_pluck( $q->get_results(), 'ID' ); 916 1098 $expected = array( self::$author_ids[0], self::$author_ids[1], self::$author_ids[2] ); 917 1099 918 $this->assertContains( "AND user_nicename IN ( 'peter','paul','mary' )", $q->query_where );1100 $this->assertContains( "AND user_nicename IN ( 'peter','paul','mary' )", $q->query_where ); 919 1101 $this->assertEqualSets( $expected, $found ); 920 1102 } … … 924 1106 */ 925 1107 public function test_nicename__not_in_returns_users_without_included_nicenames() { 926 wp_update_user( array( 927 'ID' => self::$author_ids[0], 928 'user_nicename' => 'peter' 929 ) ); 930 931 wp_update_user( array( 932 'ID' => self::$author_ids[1], 933 'user_nicename' => 'paul' 934 ) ); 935 936 wp_update_user( array( 937 'ID' => self::$author_ids[2], 938 'user_nicename' => 'mary' 939 ) ); 940 941 $q = new WP_User_Query( array ( 942 'nicename__not_in' => array( 'peter', 'paul', 'mary' ) 943 ) ); 944 945 $foundCount = count($q->get_results()); 1108 wp_update_user( 1109 array( 1110 'ID' => self::$author_ids[0], 1111 'user_nicename' => 'peter', 1112 ) 1113 ); 1114 1115 wp_update_user( 1116 array( 1117 'ID' => self::$author_ids[1], 1118 'user_nicename' => 'paul', 1119 ) 1120 ); 1121 1122 wp_update_user( 1123 array( 1124 'ID' => self::$author_ids[2], 1125 'user_nicename' => 'mary', 1126 ) 1127 ); 1128 1129 $q = new WP_User_Query( 1130 array( 1131 'nicename__not_in' => array( 'peter', 'paul', 'mary' ), 1132 ) 1133 ); 1134 1135 $foundCount = count( $q->get_results() ); 946 1136 $expectedCount = 10; // 13 total users minus 3 from query 947 1137 948 $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where );1138 $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where ); 949 1139 $this->assertEquals( $expectedCount, $foundCount ); 950 1140 } … … 954 1144 */ 955 1145 public function test_orderby_nicename__in() { 956 wp_update_user( array( 957 'ID' => self::$author_ids[0], 958 'user_nicename' => 'peter' 959 ) ); 960 961 wp_update_user( array( 962 'ID' => self::$author_ids[1], 963 'user_nicename' => 'paul' 964 ) ); 965 966 wp_update_user( array( 967 'ID' => self::$author_ids[2], 968 'user_nicename' => 'mary' 969 ) ); 970 971 $q = new WP_User_Query( array ( 972 'nicename__in' => array( 'mary', 'peter', 'paul' ), 973 'orderby' => 'nicename__in' 974 ) ); 975 976 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1146 wp_update_user( 1147 array( 1148 'ID' => self::$author_ids[0], 1149 'user_nicename' => 'peter', 1150 ) 1151 ); 1152 1153 wp_update_user( 1154 array( 1155 'ID' => self::$author_ids[1], 1156 'user_nicename' => 'paul', 1157 ) 1158 ); 1159 1160 wp_update_user( 1161 array( 1162 'ID' => self::$author_ids[2], 1163 'user_nicename' => 'mary', 1164 ) 1165 ); 1166 1167 $q = new WP_User_Query( 1168 array( 1169 'nicename__in' => array( 'mary', 'peter', 'paul' ), 1170 'orderby' => 'nicename__in', 1171 ) 1172 ); 1173 1174 $found = wp_list_pluck( $q->get_results(), 'ID' ); 977 1175 $expected = array( self::$author_ids[2], self::$author_ids[0], self::$author_ids[1] ); 978 1176 979 $this->assertContains( "FIELD( user_nicename, 'mary','peter','paul' )", $q->query_orderby );1177 $this->assertContains( "FIELD( user_nicename, 'mary','peter','paul' )", $q->query_orderby ); 980 1178 $this->assertSame( $expected, $found ); 981 1179 } … … 988 1186 $user_login = get_userdata( self::$author_ids[0] )->user_login; 989 1187 990 $q = new WP_User_Query( array ( 991 'login' => $user_login 992 ) ); 993 994 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1188 $q = new WP_User_Query( 1189 array( 1190 'login' => $user_login, 1191 ) 1192 ); 1193 1194 $found = wp_list_pluck( $q->get_results(), 'ID' ); 995 1195 $expected = array( self::$author_ids[0] ); 996 1196 997 $this->assertContains( "AND user_login = '$user_login'", $q->query_where );998 $this->assertEqualSets( $expected, $found );1197 $this->assertContains( "AND user_login = '$user_login'", $q->query_where ); 1198 $this->assertEqualSets( $expected, $found ); 999 1199 } 1000 1200 … … 1007 1207 $user_login3 = get_userdata( self::$author_ids[2] )->user_login; 1008 1208 1009 $q = new WP_User_Query( array ( 1010 'login__in' => array( $user_login1, $user_login2, $user_login3 ) 1011 ) ); 1012 1013 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1209 $q = new WP_User_Query( 1210 array( 1211 'login__in' => array( $user_login1, $user_login2, $user_login3 ), 1212 ) 1213 ); 1214 1215 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1014 1216 $expected = array( self::$author_ids[0], self::$author_ids[1], self::$author_ids[2] ); 1015 1217 1016 $this->assertContains( "AND user_login IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );1218 $this->assertContains( "AND user_login IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where ); 1017 1219 $this->assertEqualSets( $expected, $found ); 1018 1220 } … … 1026 1228 $user_login3 = get_userdata( self::$author_ids[2] )->user_login; 1027 1229 1028 $q = new WP_User_Query( array ( 1029 'login__not_in' => array( $user_login1, $user_login2, $user_login3 ) 1030 ) ); 1031 1032 $foundCount = count($q->get_results()); 1230 $q = new WP_User_Query( 1231 array( 1232 'login__not_in' => array( $user_login1, $user_login2, $user_login3 ), 1233 ) 1234 ); 1235 1236 $foundCount = count( $q->get_results() ); 1033 1237 $expectedCount = 10; // 13 total users minus 3 from query 1034 1238 1035 $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );1239 $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where ); 1036 1240 $this->assertEquals( $expectedCount, $foundCount ); 1037 1241 } … … 1045 1249 $user_login3 = get_userdata( self::$author_ids[2] )->user_login; 1046 1250 1047 $q = new WP_User_Query( array ( 1048 'login__in' => array( $user_login2, $user_login3, $user_login1 ), 1049 'orderby' => 'login__in' 1050 ) ); 1051 1052 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1251 $q = new WP_User_Query( 1252 array( 1253 'login__in' => array( $user_login2, $user_login3, $user_login1 ), 1254 'orderby' => 'login__in', 1255 ) 1256 ); 1257 1258 $found = wp_list_pluck( $q->get_results(), 'ID' ); 1053 1259 $expected = array( self::$author_ids[1], self::$author_ids[2], self::$author_ids[0] ); 1054 1260 1055 $this->assertContains( "FIELD( user_login, '$user_login2','$user_login3','$user_login1' )", $q->query_orderby );1261 $this->assertContains( "FIELD( user_login, '$user_login2','$user_login3','$user_login1' )", $q->query_orderby ); 1056 1262 $this->assertSame( $expected, $found ); 1057 1263 } … … 1061 1267 */ 1062 1268 public function test_paged() { 1063 $q = new WP_User_Query( array( 1064 'number' => 2, 1065 'paged' => 2, 1066 'orderby' => 'ID', 1067 'order' => 'DESC', // Avoid funkiness with user 1. 1068 'fields' => 'ids', 1069 ) ); 1269 $q = new WP_User_Query( 1270 array( 1271 'number' => 2, 1272 'paged' => 2, 1273 'orderby' => 'ID', 1274 'order' => 'DESC', // Avoid funkiness with user 1. 1275 'fields' => 'ids', 1276 ) 1277 ); 1070 1278 1071 1279 $this->assertEquals( array( self::$contrib_id, self::$editor_ids[2] ), $q->results ); … … 1117 1325 */ 1118 1326 public function test_get_single_role_by_string() { 1119 $users = get_users( array( 1120 'role' => 'subscriber', 1121 ) ); 1327 $users = get_users( 1328 array( 1329 'role' => 'subscriber', 1330 ) 1331 ); 1122 1332 1123 1333 $this->assertEquals( 2, count( $users ) ); … … 1128 1338 */ 1129 1339 public function test_get_single_role_by_string_which_is_similar() { 1130 $another_editor = self::factory()->user->create( array( 1131 'user_email' => 'another_editor@another_editor.com', 1132 'user_login' => 'another_editor', 1133 'role' => 'another-editor', 1134 ) ); 1135 1136 $users = get_users( array( 1137 'role' => 'editor', 1138 'fields' => 'ids', 1139 ) ); 1340 $another_editor = self::factory()->user->create( 1341 array( 1342 'user_email' => 'another_editor@another_editor.com', 1343 'user_login' => 'another_editor', 1344 'role' => 'another-editor', 1345 ) 1346 ); 1347 1348 $users = get_users( 1349 array( 1350 'role' => 'editor', 1351 'fields' => 'ids', 1352 ) 1353 ); 1140 1354 1141 1355 $this->assertEqualSets( self::$editor_ids, $users ); … … 1147 1361 */ 1148 1362 public function test_get_single_role_by_array() { 1149 $users = get_users( array( 1150 'role' => array( 'subscriber' ), 1151 ) ); 1363 $users = get_users( 1364 array( 1365 'role' => array( 'subscriber' ), 1366 ) 1367 ); 1152 1368 1153 1369 $this->assertEquals( 2, count( $users ) ); … … 1196 1412 */ 1197 1413 public function test_get_multiple_roles_by_comma_separated_list() { 1198 $users = get_users( array( 1199 'role' => 'subscriber, editor', 1200 ) ); 1414 $users = get_users( 1415 array( 1416 'role' => 'subscriber, editor', 1417 ) 1418 ); 1201 1419 1202 1420 $this->assertEmpty( $users ); … … 1207 1425 } 1208 1426 1209 $users = get_users( array( 1210 'role' => 'subscriber, editor', 1211 ) ); 1427 $users = get_users( 1428 array( 1429 'role' => 'subscriber, editor', 1430 ) 1431 ); 1212 1432 1213 1433 $this->assertEquals( 2, count( $users ) ); … … 1235 1455 1236 1456 // Fetch users 1237 $users = get_users( array( 1238 'role__in' => array( 'administrator', 'editor', 'subscriber' ), 1239 'meta_query' => array( 1240 'relation' => 'AND', 1241 array( 1242 'key' => 'mk1', 1243 'value' => '1', 1244 'compare' => "=", 1245 'type' => 'numeric', 1457 $users = get_users( 1458 array( 1459 'role__in' => array( 'administrator', 'editor', 'subscriber' ), 1460 'meta_query' => array( 1461 'relation' => 'AND', 1462 array( 1463 'key' => 'mk1', 1464 'value' => '1', 1465 'compare' => '=', 1466 'type' => 'numeric', 1467 ), 1468 array( 1469 'key' => 'mk2', 1470 'value' => '2', 1471 'compare' => '=', 1472 'type' => 'numeric', 1473 ), 1246 1474 ), 1247 array( 1248 'key' => 'mk2', 1249 'value' => '2', 1250 'compare' => "=", 1251 'type' => 'numeric', 1252 ), 1253 ), 1254 ) ); 1475 ) 1476 ); 1255 1477 1256 1478 // Check results … … 1263 1485 */ 1264 1486 public function test_role_exclusion() { 1265 $users = get_users( array( 1266 'role__not_in' => 'subscriber', 1267 ) ); 1487 $users = get_users( 1488 array( 1489 'role__not_in' => 'subscriber', 1490 ) 1491 ); 1268 1492 1269 1493 // +1 for the default user created during installation. 1270 1494 $this->assertEquals( 11, count( $users ) ); 1271 1495 1272 $users = get_users( array( 1273 'role__not_in' => 'editor', 1274 ) ); 1496 $users = get_users( 1497 array( 1498 'role__not_in' => 'editor', 1499 ) 1500 ); 1275 1501 1276 1502 // +1 for the default user created during installation. … … 1287 1513 } 1288 1514 1289 $users = get_users( array( 1290 'role__in' => 'editor', 1291 ) ); 1515 $users = get_users( 1516 array( 1517 'role__in' => 'editor', 1518 ) 1519 ); 1292 1520 1293 1521 $this->assertEquals( 5, count( $users ) ); 1294 1522 1295 $users = get_users( array( 1296 'role__in' => 'editor', 1297 'role__not_in' => 'subscriber', 1298 ) ); 1523 $users = get_users( 1524 array( 1525 'role__in' => 'editor', 1526 'role__not_in' => 'subscriber', 1527 ) 1528 ); 1299 1529 1300 1530 $this->assertEquals( 3, count( $users ) ); … … 1308 1538 $subscriber->add_role( 'editor' ); 1309 1539 1310 $users = get_users( array( 1311 'role' => 'subscriber', 1312 'role__not_in' => array( 'editor' ), 1313 ) ); 1540 $users = get_users( 1541 array( 1542 'role' => 'subscriber', 1543 'role__not_in' => array( 'editor' ), 1544 ) 1545 ); 1314 1546 1315 1547 $this->assertEquals( 1, count( $users ) ); … … 1324 1556 $user_without_rule->remove_role( 'subscriber' ); 1325 1557 1326 $users = get_users( array( 1327 'role__not_in' => 'subscriber', 1328 ) ); 1558 $users = get_users( 1559 array( 1560 'role__not_in' => 'subscriber', 1561 ) 1562 ); 1329 1563 1330 1564 // +1 for the default user created during installation. 1331 1565 $this->assertEquals( 12, count( $users ) ); 1332 1566 1333 $users = get_users( array( 1334 'role__not_in' => 'editor', 1335 ) ); 1567 $users = get_users( 1568 array( 1569 'role__not_in' => 'editor', 1570 ) 1571 ); 1336 1572 1337 1573 // +1 for the default user created during installation. … … 1349 1585 add_user_to_blog( $sites[1], self::$author_ids[1], 'author' ); 1350 1586 1351 $found = get_users( array( 1352 'blog_id' => $sites[1], 1353 'fields' => 'ID', 1354 ) ); 1587 $found = get_users( 1588 array( 1589 'blog_id' => $sites[1], 1590 'fields' => 'ID', 1591 ) 1592 ); 1355 1593 1356 1594 $this->assertEqualSets( array( self::$author_ids[1] ), $found ); … … 1366 1604 add_user_to_blog( $site_id, self::$author_ids[0], 'author' ); 1367 1605 1368 $q = new WP_User_Query( array( 1369 'include' => self::$author_ids[0], 1370 ) ); 1606 $q = new WP_User_Query( 1607 array( 1608 'include' => self::$author_ids[0], 1609 ) 1610 ); 1371 1611 1372 1612 $r1 = $q->request; 1373 1613 1374 $q->prepare_query( array( 1375 'include' => self::$author_ids[0], 1376 ) ); 1614 $q->prepare_query( 1615 array( 1616 'include' => self::$author_ids[0], 1617 ) 1618 ); 1377 1619 1378 1620 $r2 = $q->request; 1379 1621 1380 $q->prepare_query( array( 1381 'include' => self::$author_ids[0], 1382 ) ); 1622 $q->prepare_query( 1623 array( 1624 'include' => self::$author_ids[0], 1625 ) 1626 ); 1383 1627 1384 1628 $r3 = $q->request; … … 1393 1637 public function test_search_by_display_name_only() { 1394 1638 1395 $new_user1 = $this->factory->user->create( array( 1396 'user_login' => 'name1', 1397 'display_name' => 'Sophia Andresen', 1398 ) ); 1639 $new_user1 = $this->factory->user->create( 1640 array( 1641 'user_login' => 'name1', 1642 'display_name' => 'Sophia Andresen', 1643 ) 1644 ); 1399 1645 self::$author_ids[] = $new_user1; 1400 1646 1401 $q = new WP_User_Query( array( 1402 'search' => '*Sophia*', 1403 'fields' => '', 1404 'search_columns' => array( 'display_name' ), 1405 'include' => self::$author_ids, 1406 ) ); 1647 $q = new WP_User_Query( 1648 array( 1649 'search' => '*Sophia*', 1650 'fields' => '', 1651 'search_columns' => array( 'display_name' ), 1652 'include' => self::$author_ids, 1653 ) 1654 ); 1407 1655 1408 1656 $ids = $q->get_results(); … … 1417 1665 public function test_search_by_display_name_only_ignore_others() { 1418 1666 1419 $new_user1 = $this->factory->user->create( array( 1420 'user_login' => 'Sophia Andresen', 1421 'display_name' => 'name1', 1422 ) ); 1667 $new_user1 = $this->factory->user->create( 1668 array( 1669 'user_login' => 'Sophia Andresen', 1670 'display_name' => 'name1', 1671 ) 1672 ); 1423 1673 self::$author_ids[] = $new_user1; 1424 1674 1425 $q = new WP_User_Query( array( 1426 'search' => '*Sophia*', 1427 'fields' => '', 1428 'search_columns' => array( 'display_name' ), 1429 'include' => self::$author_ids, 1430 ) ); 1675 $q = new WP_User_Query( 1676 array( 1677 'search' => '*Sophia*', 1678 'fields' => '', 1679 'search_columns' => array( 'display_name' ), 1680 'include' => self::$author_ids, 1681 ) 1682 ); 1431 1683 1432 1684 $ids = $q->get_results();
Note: See TracChangeset
for help on using the changeset viewer.