WordPress.org

Make WordPress Core

Ticket #24618: 24618-tests.patch

File 24618-tests.patch, 780 bytes (added by mordauk, 8 years ago)

Unit tests for validate_username()

  • tests/phpunit/tests/user.php

     
    627627                // If this test fails, it will error out for calling the to_array() method on a non-object.
    628628                $this->assertInstanceOf( 'WP_Error', wp_update_user( array( 'ID' => $user_id ) ) );
    629629        }
     630
     631        /**
     632         * @ticket 24618
     633         */
     634        function test_validate_username() {
     635
     636                $this->assertTrue( validate_username( 'testusername' ) );
     637                $this->assertTrue( validate_username( 'JohnDoe' ) );
     638                $this->assertTrue( validate_username( 'test@test.com' ) );
     639                $this->assertFalse( validate_username( '' ) );
     640                $this->assertFalse( validate_username( '@#&99sd' ) );
     641
     642        }
     643       
    630644}