Make WordPress Core


Ignore:
Timestamp:
07/01/2017 02:21:50 PM (9 years ago)
Author:
boonebgorges
Message:

Allow user searches to match the display_name field.

Props bcole808, pcarvalho.
Fixes #39643.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user/query.php

    r40564 r40982  
    13871387                $this->assertSame( $r1, $r3 );
    13881388        }
     1389
     1390        /**
     1391         * @ticket 39643
     1392         */
     1393        public function test_search_by_display_name_only() {
     1394
     1395                $new_user1 = $this->factory->user->create( array(
     1396                        'user_login'   => 'name1',
     1397                        'display_name' => 'Sophia Andresen',
     1398                ) );
     1399                self::$author_ids[] = $new_user1;
     1400
     1401                $q = new WP_User_Query( array(
     1402                        'search' => '*Sophia*',
     1403                        'fields' => '',
     1404                        'search_columns' => array( 'display_name' ),
     1405                        'include' => self::$author_ids,
     1406                ) );
     1407
     1408                $ids = $q->get_results();
     1409
     1410                /* must include user that has same string in display_name */
     1411                $this->assertEquals( array( $new_user1 ), $ids );
     1412        }
     1413
     1414        /**
     1415         * @ticket 39643
     1416         */
     1417        public function test_search_by_display_name_only_ignore_others() {
     1418
     1419                $new_user1 = $this->factory->user->create( array(
     1420                        'user_login'   => 'Sophia Andresen',
     1421                        'display_name' => 'name1',
     1422                ) );
     1423                self::$author_ids[] = $new_user1;
     1424
     1425                $q = new WP_User_Query( array(
     1426                        'search' => '*Sophia*',
     1427                        'fields' => '',
     1428                        'search_columns' => array( 'display_name' ),
     1429                        'include' => self::$author_ids,
     1430                ) );
     1431
     1432                $ids = $q->get_results();
     1433
     1434                /* must not include user that has same string in other fields */
     1435                $this->assertEquals( array(), $ids );
     1436        }
    13891437}
Note: See TracChangeset for help on using the changeset viewer.