WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/06/2015 05:34:47 AM (4 years ago)
Author:
DrewAPicture
Message:

Users: Empty sanitized usernames should be considered invalid when passed through validate_username().

Adds tests.

Props gwinhlopez for the initial patch.
Props mordauk, chriscct7.
Fixes #24618.

File:
1 edited

Legend:

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

    r34626 r34856  
    598598            }
    599599        }
     600    }
     601
     602    /**
     603     * @ticket 24618
     604     */
     605    public function test_validate_username_string() {
     606        $this->assertTrue( validate_username( rand_str() ) );
     607        $this->assertTrue( validate_username( 'JohnDoe' ) );
     608        $this->assertTrue( validate_username( 'test@test.com' ) );
     609    }
     610
     611    /**
     612     * @ticket 24618
     613     */
     614    public function test_validate_username_empty() {
     615        $this->assertFalse( validate_username( '' ) );
     616    }
     617
     618    /**
     619     * @ticket 24618
     620     */
     621    public function test_validate_username_invalid() {
     622        $this->assertFalse( validate_username( '@#&99sd' ) );
    600623    }
    601624
Note: See TracChangeset for help on using the changeset viewer.