Ticket #31106: 31106.diff
File 31106.diff, 1.2 KB (added by , 10 years ago) |
---|
-
src/wp-includes/user.php
1630 1630 } 1631 1631 1632 1632 /** 1633 * Checks whether a given nicename exists. 1634 * 1635 * @since 4.2.0 1636 * 1637 * @param string $nicename Nicename. 1638 * @return null|int The user's ID on success, and null on failure. 1639 */ 1640 function nicename_exists( $nicename ) { 1641 if ( $user = get_user_by( 'slug', $nicename ) ) { 1642 return $user->ID; 1643 } else { 1644 return null; 1645 } 1646 } 1647 1648 /** 1633 1649 * Checks whether the given email exists. 1634 1650 * 1635 1651 * @since 2.1.0 -
tests/phpunit/tests/user.php
664 664 $user = get_userdata( $user->ID ); 665 665 $this->assertEmpty( $user->user_activation_key ); 666 666 } 667 668 function test_nicename_exists() { 669 $user_id = $this->factory->user->create( array( 'user_nicename' => 'nicenameexists' ) ); 670 $this->assertEquals( nicename_exists( 'nicenameexists' ), $user_id ); 671 wp_delete_user( $user_id ); 672 $this->assertEquals( null, nicename_exists( 'nicenameexists' ) ); 673 } 667 674 }