Add tests for current behavior of wp_set_current_user().

See #20845.

git-svn-id: https://develop.svn.wordpress.org/trunk@34945 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-10-08 17:19:00 +00:00
parent 4dc569f748
commit 5c496e841a

View File

@ -0,0 +1,27 @@
<?php
/**
* @group user
*/
class Tests_User_WpSetCurrentUser extends WP_UnitTestCase {
public function test_set_by_id() {
$u = $this->factory->user->create();
$user = wp_set_current_user( $u );
$this->assertSame( $u, $user->ID );
$this->assertEquals( $user, wp_get_current_user() );
$this->assertSame( $u, get_current_user_id() );
}
public function test_name_should_be_ignored_if_id_is_not_null() {
$u = $this->factory->user->create();
$user = wp_set_current_user( $u, 'foo' );
$this->assertSame( $u, $user->ID );
$this->assertEquals( $user, wp_get_current_user() );
$this->assertSame( $u, get_current_user_id() );
}
}