From 374f27176bb1d5b47ecf277039e1be95794937c2 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 20 Feb 2017 21:42:48 +0100 Subject: [PATCH] Add tests for method 'registerWithUniqueUsername' in class 'Auth' --- tests/index.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/index.php b/tests/index.php index 1599f78..f7dae0d 100644 --- a/tests/index.php +++ b/tests/index.php @@ -86,7 +86,16 @@ function processRequestData(\Delight\Auth\Auth $auth) { $callback = null; } - return $auth->register($_POST['email'], $_POST['password'], $_POST['username'], $callback); + if (!isset($_POST['require_unique_username'])) { + $_POST['require_unique_username'] = '0'; + } + + if ($_POST['require_unique_username'] == 0) { + return $auth->register($_POST['email'], $_POST['password'], $_POST['username'], $callback); + } + else { + return $auth->registerWithUniqueUsername($_POST['email'], $_POST['password'], $_POST['username'], $callback); + } } catch (\Delight\Auth\InvalidEmailException $e) { return 'invalid email address'; @@ -95,7 +104,10 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'invalid password'; } catch (\Delight\Auth\UserAlreadyExistsException $e) { - return 'user already exists'; + return 'email address already exists'; + } + catch (\Delight\Auth\DuplicateUsernameException $e) { + return 'username already exists'; } catch (\Delight\Auth\TooManyRequestsException $e) { return 'too many requests'; @@ -275,6 +287,10 @@ function showGuestUserForm() { echo ''; echo ''; echo ' '; + echo ' '; echo ''; echo '';