From 4debbf1f38bf4930f71a4f33285c2d744a428da8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 5 Jun 2019 15:33:48 +1000 Subject: [PATCH] Tests for unique users --- app/Http/Middleware/TokenAuth.php | 3 ++- app/Listeners/User/UpdateUserLastLogin.php | 2 +- tests/Integration/UniqueEmailTest.php | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Http/Middleware/TokenAuth.php b/app/Http/Middleware/TokenAuth.php index c2da2bb4f4..48d5f3d983 100644 --- a/app/Http/Middleware/TokenAuth.php +++ b/app/Http/Middleware/TokenAuth.php @@ -11,6 +11,7 @@ namespace App\Http\Middleware; +use App\Events\User\UserLoggedIn; use App\Models\CompanyToken; use App\Models\User; use Closure; @@ -31,7 +32,7 @@ class TokenAuth { auth()->login($user); - event(); + event(new UserLoggedIn($user)); } else { diff --git a/app/Listeners/User/UpdateUserLastLogin.php b/app/Listeners/User/UpdateUserLastLogin.php index f7ddfe44b2..12d112e8b4 100644 --- a/app/Listeners/User/UpdateUserLastLogin.php +++ b/app/Listeners/User/UpdateUserLastLogin.php @@ -38,7 +38,7 @@ class UpdateUserLastLogin $user = $event->user; - $user->last_login = now() + $user->last_login = now(); $user->save(); } diff --git a/tests/Integration/UniqueEmailTest.php b/tests/Integration/UniqueEmailTest.php index e74958e848..23a4ceb736 100644 --- a/tests/Integration/UniqueEmailTest.php +++ b/tests/Integration/UniqueEmailTest.php @@ -2,7 +2,7 @@ namespace Tests\Integration; -use App\Http\ValidationRules\UniqueUserRule; +use App\Http\ValidationRules\NewUniqueUserRule; use App\Models\Account; use App\Models\Company; use App\Models\User; @@ -14,7 +14,7 @@ use Tests\TestCase; /** * @test - * @covers App\Utils\NumberHelper + * @covers App\Http\ValidationRules\NewUniqueUserRule */ class UniqueEmailTest extends TestCase { @@ -30,7 +30,7 @@ class UniqueEmailTest extends TestCase DB::connection('db-ninja-01')->table('users')->delete(); DB::connection('db-ninja-02')->table('users')->delete(); - $this->rule = new UniqueUserRule(); + $this->rule = new NewUniqueUserRule(); $ac = factory(\App\Models\Account::class)->make();