Ejemplo n.º 1
0
    $hex_chars = array_merge($hex_chars, str_split($hex));
    $custom_chars = array_merge($custom_chars, str_split($custom));
}
$ascii_chars = array_unique($ascii_chars);
$alpha_chars = array_unique($alpha_chars);
$hex_chars = array_unique($hex_chars);
$custom_chars = array_unique($custom_chars);
if (count($ascii_chars) !== 94) {
    failTest("Not all ASCII chars are included.");
}
if (count($alpha_chars) !== 62) {
    failTest("Not all AlphaNumeric chars are included.");
}
if (count($hex_chars) !== 16) {
    failTest("Not all Hex chars are included.");
}
if (count($custom_chars) !== 2) {
    failTest("Not all Custom chars are included.");
}
if (PasswordGenerator::getCustomPassword("abc", 64) !== false) {
    failTest("Improper usage does not return false.");
}
for ($i = 0; $i < 1000; $i++) {
    $ints = PasswordGenerator::getRandomInts($i);
    $count = count($ints);
    if ($count != $i) {
        failTest("{$i} random ints is {$count} and not {$i}");
    }
}
echo "ALL TESTS PASS!\n";
exit(0);