From 5c496e841a06d057eda90269926b1e0eb0217892 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 8 Oct 2015 17:19:00 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/user/wpSetCurrentUser.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/phpunit/tests/user/wpSetCurrentUser.php diff --git a/tests/phpunit/tests/user/wpSetCurrentUser.php b/tests/phpunit/tests/user/wpSetCurrentUser.php new file mode 100644 index 0000000000..c47c22cc74 --- /dev/null +++ b/tests/phpunit/tests/user/wpSetCurrentUser.php @@ -0,0 +1,27 @@ +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() ); + } +} +