summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit/includes/class-wp-fake-hasher.php
blob: 4ebbca84b5fe939a1ebdbc501b2514ef7541d20f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
 * WP_Fake_Hasher for testing
 *
 * @package WordPress
 * @since 6.8.0
 */

/**
 * Test class.
 *
 * @since 6.8.0
 */
class WP_Fake_Hasher {
	private $hash = '';

	public function __construct() {
		$this->hash = str_repeat( 'a', 36 );
	}

	/**
	 * Hashes a password.
	 *
	 * @param string $password Password to hash.
	 * @return string Hashed password.
	 */
	public function HashPassword( string $password ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
		return $this->hash;
	}

	/**
	 * Checks the password hash.
	 *
	 * @param string $password Password to check.
	 * @param string $hash     Hash to check against.
	 * @return bool Whether the password hash is valid.
	 */
	public function CheckPassword( string $password, string $hash ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
		return $hash === $this->hash;
	}
}