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:
parent
4dc569f748
commit
5c496e841a
27
tests/phpunit/tests/user/wpSetCurrentUser.php
Normal file
27
tests/phpunit/tests/user/wpSetCurrentUser.php
Normal 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() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user