From 2e4d38cbf4cd6afa92b77395c440d17f62beba69 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Thu, 21 Nov 2013 23:02:33 +0100 Subject: [PATCH] Test to check that the token is properly generated --- src/Poche/Util/Token.php | 2 +- tests/units/Token.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/units/Token.php diff --git a/src/Poche/Util/Token.php b/src/Poche/Util/Token.php index c6c32b0..598ac2b 100644 --- a/src/Poche/Util/Token.php +++ b/src/Poche/Util/Token.php @@ -15,7 +15,7 @@ class Token return substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); } else { - return substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); + return substr(base64_encode(uniqid(mt_rand(), true)), 0, 15); } } diff --git a/tests/units/Token.php b/tests/units/Token.php new file mode 100644 index 0000000..630852e --- /dev/null +++ b/tests/units/Token.php @@ -0,0 +1,17 @@ +integer(strlen(\Poche\Util\Token::generateToken())) + ->isEqualTo(15) + ; + } +} +