Skip to content

Commit

Permalink
test: update db.table config
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 31, 2024
1 parent ececd79 commit 8322bc5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/register.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

test('user can register an account', function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -31,6 +32,7 @@

test('user can login after registering', function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -51,6 +53,7 @@

test('user can only sign up once', function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand Down Expand Up @@ -78,6 +81,7 @@

test('register passwords are encrypted', function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand Down
8 changes: 8 additions & 0 deletions tests/session.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
test('register should create a new session when session => true', function () {
$auth = authInstance();
$auth->config(['session' => true]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -39,6 +40,7 @@
test('register should not create a new session when session => false', function () {
$auth = authInstance();
$auth->config(['session' => false]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user2',
Expand All @@ -58,6 +60,7 @@
test('login should create session when session => true', function () {
$auth = authInstance();
$auth->config(['session' => true]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -78,6 +81,7 @@
test('session should create auth.ttl when session.lifetime is not 0', function () {
$auth = authInstance();
$auth->config(['session' => true, 'session.lifetime' => 2]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -102,6 +106,7 @@
test('session should not create auth.ttl when session.lifetime is 0', function () {
$auth = authInstance();
$auth->config(['session' => true, 'session.lifetime' => 0]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -124,6 +129,7 @@
test('session should expire after session.lifetime', function () {
$auth = authInstance();
$auth->config(['session' => true, 'session.lifetime' => 2]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand All @@ -149,6 +155,7 @@
test('login should regenerate session id when session => true and session is already active', function () {
$auth = authInstance();
$auth->config(['session' => true]);
$auth->config(['db.table' => 'users']);

session_start();

Expand Down Expand Up @@ -177,6 +184,7 @@
test('logout should remove auth info from session when session => true', function () {
$auth = authInstance();
$auth->config(['session' => true]);
$auth->config(['db.table' => 'users']);

$userData = [
'username' => 'test-user',
Expand Down
4 changes: 4 additions & 0 deletions tests/update.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

test('update should update user data', function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$success = $auth->login([
'username' => 'test-user-1',
Expand All @@ -49,6 +50,7 @@

test('update should fail if user already exists', function () {
$auth = authInstance();
$auth->config(['db.table' => 'users']);

$success = $auth->login([
'username' => 'test-user-3',
Expand All @@ -72,6 +74,7 @@
test('updatePassword should update user password', function () {
$auth = authInstance();
$auth->config(['unique' => ['username']]);
$auth->config(['db.table' => 'users']);

$success = $auth->login([
'username' => 'test-user-2',
Expand Down Expand Up @@ -103,6 +106,7 @@
test('update should regenerate session id if session => true', function () {
$auth = authInstance();
$auth->config(['session' => true]);
$auth->config(['db.table' => 'users']);

$success = $auth->login([
'username' => 'test-user-2',
Expand Down

0 comments on commit 8322bc5

Please sign in to comment.