From 395db961dcc30aca0f215a5236e49d57bed6b808 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Fri, 29 Oct 2021 02:17:45 -0700 Subject: [PATCH] =?UTF-8?q?test:=20add=20final=20test=20for=20100%=20cover?= =?UTF-8?q?age=20=F0=9F=92=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Unit/UserPasswordTest.php | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Unit/UserPasswordTest.php b/tests/Unit/UserPasswordTest.php index 8297060..ae46371 100644 --- a/tests/Unit/UserPasswordTest.php +++ b/tests/Unit/UserPasswordTest.php @@ -80,4 +80,40 @@ public function phpass_passwords_should_be_verified_and_converted_to_bcrypt() wp_check_password(Constants::PASSWORD, Constants::PHPPASS_HASH, Constants::USER_ID) ); } + + /** @test */ + public function wp_hasher_global_should_be_automatically_assigned() + { + global $wp_hasher; + + $this + ->wpdb() + ->shouldReceive('update') + ->withAnyArgs() + ->andReturnNull(); + + $this + ->wpHasher() // 👈🏼 global is assigned here + ->shouldReceive('CheckPassword') + ->once() + ->with(Constants::PASSWORD, Constants::PHPPASS_HASH) + ->andReturn(true); + + expect('clean_user_cache') + ->once() + ->andReturn(true); + + + $class_name = get_class($wp_hasher); + $wp_hasher = null; + + + $this->assertNotInstanceOf($class_name, $wp_hasher); + + $this->assertTrue( + wp_check_password(Constants::PASSWORD, Constants::PHPPASS_HASH, Constants::USER_ID) + ); + + $this->assertInstanceOf($class_name, $wp_hasher); + } }