Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 31, 2024
1 parent 09eb3ed commit 44dfa9d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/register.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

beforeAll(function () {
createTableForUsers();
dbInstance()->delete('users')->execute();
});

afterEach(function () {
dbInstance()->delete('users')->where('username', 'test-user')->execute();
dbInstance()->delete('users')->execute();
});

test('user can register an account', function (array $userData) {
$auth = authInstance();

$success = $auth->register($userData);

if (!$success) {
$this->fail(json_encode($auth->errors()));
}

expect($success)->toBeTrue();
expect($auth->user())->toBeInstanceOf(\Leaf\Auth\User::class);
expect($auth->user()->username)->toBe($userData['username']);
Expand Down
5 changes: 5 additions & 0 deletions tests/session.test.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php

beforeAll(function () {
createTableForUsers();
dbInstance()->delete('users')->execute();
});

afterEach(function () {
if (session_status() === PHP_SESSION_ACTIVE) {
$_SESSION = [];
Expand Down
1 change: 1 addition & 0 deletions tests/user.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

beforeAll(function () {
createTableForUsers();
dbInstance()->delete('users')->execute();

try {
dbInstance()
Expand Down

0 comments on commit 44dfa9d

Please sign in to comment.