summaryrefslogtreecommitdiff
path: root/ext/standard/tests/password/password_hash_error.phpt
blob: 0dc056ea34b216a1ca4e109fc15392a75d1fc03d (plain)
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
42
43
44
45
--TEST--
Test error operation of password_hash()
--FILE--
<?php
//-=-=-=-

try {
    var_dump(password_hash("foo"));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

try {
    password_hash("foo", array());
} catch (ValueError $exception) {
    echo $exception->getMessage() . "\n";
}

try {
    var_dump(password_hash("foo", 19, new StdClass));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

try {
    var_dump(password_hash("foo", PASSWORD_BCRYPT, "baz"));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

try {
    var_dump(password_hash(array(), PASSWORD_BCRYPT));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}

?>
--EXPECTF--
password_hash() expects at least 2 parameters, 1 given

Warning: Array to string conversion in %s on line %d
password_hash(): Argument #2 ($algo) must be a valid password hashing algorithm
password_hash(): Argument #3 ($options) must be of type array, stdClass given
password_hash(): Argument #3 ($options) must be of type array, string given
password_hash(): Argument #1 ($password) must be of type string, array given