Make WordPress Core


Ignore:
Timestamp:
07/07/2015 07:28:46 PM (11 years ago)
Author:
wonderboymusic
Message:

In wp_insert_user(), comparing an email address against the user's old email address should not be case-sensitive.

Adds unit tests.

Props tyxla.
Fixes #32158.

File:
1 edited

Legend:

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

    r32980 r33115  
    757757                $this->assertTrue( in_array( $id, $users ) );
    758758        }
     759
     760        /**
     761         * @ticket 32158
     762         */
     763        function test_email_case() {
     764                // Create a test user with a lower-case email address.
     765                $user_id = $this->factory->user->create( array(
     766                        'user_email' => 'test@test.com',
     767                ) );
     768
     769                // Alter the case of the email address (which stays the same).
     770                $userdata = array(
     771                        'ID' => $user_id,
     772                        'user_email' => 'test@TEST.com',
     773                );
     774                $update = wp_update_user( $userdata );
     775
     776                $this->assertEquals( $user_id, $update );
     777        }
     778
     779        /**
     780         * @ticket 32158
     781         */
     782        function test_email_change() {
     783                // Create a test user.
     784                $user_id = $this->factory->user->create( array(
     785                        'user_email' => 'test@test.com',
     786                ) );
     787
     788                // Change the email address.
     789                $userdata = array(
     790                        'ID' => $user_id,
     791                        'user_email' => 'test2@test.com',
     792                );
     793                $update = wp_update_user( $userdata );
     794
     795                // Was this successful?
     796                $this->assertEquals( $user_id, $update );
     797
     798                // Verify that the email address has been updated.
     799                $user = get_userdata( $user_id );
     800                $this->assertEquals( $user->user_email, 'test2@test.com' );
     801        }
     802
    759803}
Note: See TracChangeset for help on using the changeset viewer.