| 1429 | |
| 1430 | /** |
| 1431 | * @ticket 39643 |
| 1432 | */ |
| 1433 | public function test_search_by_display_name_only() { |
| 1434 | |
| 1435 | $new_user1 = $this->factory->user->create( array( |
| 1436 | 'user_login' => 'name1', |
| 1437 | 'display_name' => 'Sophia Andresen', |
| 1438 | ) ); |
| 1439 | self::$author_ids[] = $new_user1; |
| 1440 | |
| 1441 | $q = new WP_User_Query( array( |
| 1442 | 'search' => '*Sophia*', |
| 1443 | 'fields' => '', |
| 1444 | 'search_columns' => array( 'display_name' ), |
| 1445 | 'include' => self::$author_ids, |
| 1446 | ) ); |
| 1447 | |
| 1448 | $ids = $q->get_results(); |
| 1449 | |
| 1450 | /* must include user that has same string in display_name */ |
| 1451 | $this->assertEquals( array( $new_user1 ), $ids ); |
| 1452 | } |
| 1453 | |
| 1454 | /** |
| 1455 | * @ticket 39643 |
| 1456 | */ |
| 1457 | public function test_search_by_display_name_only_ignore_others() { |
| 1458 | |
| 1459 | $new_user1 = $this->factory->user->create( array( |
| 1460 | 'user_login' => 'Sophia Andresen', |
| 1461 | 'display_name' => 'name1', |
| 1462 | ) ); |
| 1463 | self::$author_ids[] = $new_user1; |
| 1464 | |
| 1465 | $q = new WP_User_Query( array( |
| 1466 | 'search' => '*Sophia*', |
| 1467 | 'fields' => '', |
| 1468 | 'search_columns' => array( 'display_name' ), |
| 1469 | 'include' => self::$author_ids, |
| 1470 | ) ); |
| 1471 | |
| 1472 | $ids = $q->get_results(); |
| 1473 | |
| 1474 | /* must not include user that has same string in other fields */ |
| 1475 | $this->assertEquals( array(), $ids ); |
| 1476 | } |