Skip to content

Commit

Permalink
test: add final test for 100% coverage 💪
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t authored and swalkinshaw committed Oct 29, 2021
1 parent 99c22d3 commit 395db96
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/Unit/UserPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 395db96

Please sign in to comment.