forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpHash.php
More file actions
39 lines (33 loc) · 808 Bytes
/
wpHash.php
File metadata and controls
39 lines (33 loc) · 808 Bytes
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
<?php
/**
* Tests for the behavior of `wp_hash()`
*
* @group functions
*
* @covers ::wp_hash
*/
class Tests_Functions_wpHash extends WP_UnitTestCase {
/**
* @dataProvider data_wp_hash_uses_specified_algorithm
*
* @ticket 62005
*/
public function test_wp_hash_uses_specified_algorithm( string $algo, int $expected_length ) {
$hash = wp_hash( 'data', 'auth', $algo );
$this->assertSame( $expected_length, strlen( $hash ) );
}
public function data_wp_hash_uses_specified_algorithm() {
return array(
array( 'md5', 32 ),
array( 'sha1', 40 ),
array( 'sha256', 64 ),
);
}
/**
* @ticket 62005
*/
public function test_wp_hash_throws_exception_on_invalid_algorithm() {
$this->expectException( 'InvalidArgumentException' );
wp_hash( 'data', 'auth', 'invalid' );
}
}