1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-03 22:57:27 +02:00

Add tests for 'getStatus' and related methods in 'Auth' class

This commit is contained in:
Marco
2017-02-26 13:45:26 +01:00
parent 93477e4e7e
commit dd51d2c07d

View File

@@ -302,6 +302,12 @@ function showDebugData(\Delight\Auth\Auth $auth, $result) {
var_dump($auth->getEmail()); var_dump($auth->getEmail());
echo '$auth->getUsername()'."\t\t\t"; echo '$auth->getUsername()'."\t\t\t";
var_dump($auth->getUsername()); var_dump($auth->getUsername());
echo '$auth->getStatus()'."\t\t\t";
echo convertStatusToText($auth);
echo ' / ';
var_dump($auth->getStatus());
echo '$auth->isRemembered()'."\t\t\t"; echo '$auth->isRemembered()'."\t\t\t";
var_dump($auth->isRemembered()); var_dump($auth->isRemembered());
echo '$auth->getIpAddress()'."\t\t\t"; echo '$auth->getIpAddress()'."\t\t\t";
@@ -316,6 +322,36 @@ function showDebugData(\Delight\Auth\Auth $auth, $result) {
echo '</pre>'; echo '</pre>';
} }
function convertStatusToText(\Delight\Auth\Auth $auth) {
if ($auth->isLoggedIn() === true) {
if ($auth->getStatus() === \Delight\Auth\Status::NORMAL && $auth->isNormal()) {
return 'normal';
}
elseif ($auth->getStatus() === \Delight\Auth\Status::ARCHIVED && $auth->isArchived()) {
return 'archived';
}
elseif ($auth->getStatus() === \Delight\Auth\Status::BANNED && $auth->isBanned()) {
return 'banned';
}
elseif ($auth->getStatus() === \Delight\Auth\Status::LOCKED && $auth->isLocked()) {
return 'locked';
}
elseif ($auth->getStatus() === \Delight\Auth\Status::PENDING_REVIEW && $auth->isPendingReview()) {
return 'pending review';
}
elseif ($auth->getStatus() === \Delight\Auth\Status::SUSPENDED && $auth->isSuspended()) {
return 'suspended';
}
}
elseif ($auth->isLoggedIn() === false) {
if ($auth->getStatus() === null) {
return 'none';
}
}
throw new Exception('Invalid status `' . $auth->getStatus() . '`');
}
function showGeneralForm() { function showGeneralForm() {
echo '<form action="" method="get" accept-charset="utf-8">'; echo '<form action="" method="get" accept-charset="utf-8">';
echo '<button type="submit">Refresh</button>'; echo '<button type="submit">Refresh</button>';