mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/15693] Update tests to reflect changes to gen_rand_string()
PHPBB3-15693
This commit is contained in:
parent
f75c400db4
commit
9e50e52fa5
2 changed files with 12 additions and 2 deletions
|
@ -66,6 +66,8 @@ function set_var(&$result, $var, $type, $multibyte = false)
|
||||||
/**
|
/**
|
||||||
* Generates an alphanumeric random string of given length
|
* Generates an alphanumeric random string of given length
|
||||||
*
|
*
|
||||||
|
* @param int $num_chars Length of random string, defaults to 8
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function gen_rand_string($num_chars = 8)
|
function gen_rand_string($num_chars = 8)
|
||||||
|
@ -78,6 +80,8 @@ function gen_rand_string($num_chars = 8)
|
||||||
* Generates a user-friendly alphanumeric random string of given length
|
* Generates a user-friendly alphanumeric random string of given length
|
||||||
* We remove 0 and O so users cannot confuse those in passwords etc.
|
* We remove 0 and O so users cannot confuse those in passwords etc.
|
||||||
*
|
*
|
||||||
|
* @param int $num_chars Length of random string, defaults to 8
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function gen_rand_string_friendly($num_chars = 8)
|
function gen_rand_string_friendly($num_chars = 8)
|
||||||
|
|
|
@ -40,7 +40,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case
|
||||||
$random_string_length = strlen($random_string);
|
$random_string_length = strlen($random_string);
|
||||||
|
|
||||||
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
|
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
|
||||||
$this->assertTrue($random_string_length <= $num_chars);
|
$this->assertTrue(
|
||||||
|
$random_string_length == $num_chars,
|
||||||
|
sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length)
|
||||||
|
);
|
||||||
$this->assertRegExp('#^[A-Z0-9]+$#', $random_string);
|
$this->assertRegExp('#^[A-Z0-9]+$#', $random_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +59,10 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case
|
||||||
$random_string_length = strlen($random_string);
|
$random_string_length = strlen($random_string);
|
||||||
|
|
||||||
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
|
$this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH);
|
||||||
$this->assertTrue($random_string_length <= $num_chars);
|
$this->assertTrue(
|
||||||
|
$random_string_length == $num_chars,
|
||||||
|
sprintf('Failed asserting that random string length matches expected length. Expected %1$u, Actual %2$u', $num_chars, $random_string_length)
|
||||||
|
);
|
||||||
$this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string);
|
$this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue