Make WordPress Core

Ticket #27304: 27304.diff

File 27304.diff, 3.0 KB (added by wonderboymusic, 10 years ago)
  • src/wp-includes/user.php

     
    797797                                elseif ( preg_match('|^https?://|', $search) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) )
    798798                                        $search_columns = array('user_url');
    799799                                else
    800                                         $search_columns = array('user_login', 'user_nicename');
     800                                        $search_columns = array('user_login', 'user_url', 'user_email', 'user_nicename', 'display_name');
    801801                        }
    802802
    803803                        /**
  • tests/phpunit/tests/user.php

     
    66 */
    77class Tests_User extends WP_UnitTestCase {
    88
     9        protected $user_data;
     10
     11        function setUp() {
     12                parent::setUp();
     13
     14                $this->user_data = array(
     15                        'user_login' => 'user1',
     16                        'user_nicename' => 'userone',
     17                        'user_pass'  => 'password',
     18                        'first_name' => 'John',
     19                        'last_name'  => 'Doe',
     20                        'display_name' => 'John Doe',
     21                        'user_email' => 'blackburn@battlefield3.com',
     22                        'user_url' => 'http://tacos.com'
     23                );
     24        }
     25
    926        function test_get_users_of_blog() {
    1027                // add one of each user role
    1128                $nusers = array();
     
    636653                ) );
    637654                $this->assertEquals( $id2, email_exists( 'miller@battlefield3.com' ) );
    638655
    639                 if( ! is_wp_error( $id2 ) ){   
     656                if( ! is_wp_error( $id2 ) ){
    640657                        $return = wp_update_user( array(
    641658                                'ID'         => $id2,
    642659                                'user_email' => 'david@battlefield3.com',
     
    649666                        ) );
    650667                        if ( ! defined( 'WP_IMPORTING' ) ) {
    651668                                $this->assertWPError( $return );
    652                         }                       
     669                        }
    653670                }
    654671        }
    655672
     
    699716                $user = get_userdata( $user->ID );
    700717                $this->assertEmpty( $user->user_activation_key );
    701718        }
     719
     720        public function test_search_users_login() {
     721                $id = $this->factory->user->create( $this->user_data );
     722
     723                $users = get_users( array( 'search' => 'user1', 'fields' => 'ID' ) );
     724
     725                $this->assertTrue( in_array( $id, $users ) );
     726        }
     727
     728        public function test_search_users_url() {
     729                $id = $this->factory->user->create( $this->user_data );
     730
     731                $users = get_users( array( 'search' => '*tacos*', 'fields' => 'ID' ) );
     732
     733                $this->assertTrue( in_array( $id, $users ) );
     734        }
     735
     736        public function test_search_users_email() {
     737                $id = $this->factory->user->create( $this->user_data );
     738
     739                $users = get_users( array( 'search' => '*battle*', 'fields' => 'ID' ) );
     740
     741                $this->assertTrue( in_array( $id, $users ) );
     742        }
     743
     744        public function test_search_users_nicename() {
     745                $id = $this->factory->user->create( $this->user_data );
     746
     747                $users = get_users( array( 'search' => '*one*', 'fields' => 'ID' ) );
     748
     749                $this->assertTrue( in_array( $id, $users ) );
     750        }
     751
     752        public function test_search_users_display_name() {
     753                $id = $this->factory->user->create( $this->user_data );
     754
     755                $users = get_users( array( 'search' => '*Doe*', 'fields' => 'ID' ) );
     756
     757                $this->assertTrue( in_array( $id, $users ) );
     758        }
    702759}