| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @group user |
| 5 | */ |
| 6 | class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { |
| 7 | |
| 8 | /** |
| 9 | * Test that you can set the current user by the name parameter |
| 10 | * |
| 11 | * Initially we expect the current user to not be set - giving ID=0 |
| 12 | * Trying to set it to "admin" should return ID=1 |
| 13 | * |
| 14 | * @ticket 20845 |
| 15 | */ |
| 16 | function test_wp_set_current_user_by_name() { |
| 17 | $user = wp_get_current_user(); |
| 18 | $this->assertEquals( $user->ID, 0 ); |
| 19 | $admin_user = wp_set_current_user( null, "admin" ); |
| 20 | $this->assertEquals( $admin_user->ID, 1 ); |
| 21 | $this->assertEquals( $admin_user->user_login, "admin" ); |
| 22 | } |
| 23 | |
| 24 | } |
| 25 | |