+++ /dev/null
-<?php
-
-namespace Tests\Feature\Auth;
-
-use App\Models\User;
-use App\Providers\RouteServiceProvider;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Tests\TestCase;
-
-class AuthenticationTest extends TestCase
-{
- use RefreshDatabase;
-
- public function test_login_screen_can_be_rendered()
- {
- $response = $this->get('/login');
-
- $response->assertStatus(200);
- }
-
- public function test_users_can_authenticate_using_the_login_screen()
- {
- $user = User::factory()->create();
-
- $response = $this->post('/login', [
- 'email' => $user->email,
- 'password' => 'password',
- ]);
-
- $this->assertAuthenticated();
- $response->assertRedirect(RouteServiceProvider::HOME);
- }
-
- public function test_users_can_not_authenticate_with_invalid_password()
- {
- $user = User::factory()->create();
-
- $this->post('/login', [
- 'email' => $user->email,
- 'password' => 'wrong-password',
- ]);
-
- $this->assertGuest();
- }
-}
+++ /dev/null
-<?php
-
-namespace Tests\Feature\Auth;
-
-use App\Models\User;
-use App\Providers\RouteServiceProvider;
-use Illuminate\Auth\Events\Verified;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Illuminate\Support\Facades\Event;
-use Illuminate\Support\Facades\URL;
-use Tests\TestCase;
-
-class EmailVerificationTest extends TestCase
-{
- use RefreshDatabase;
-
- public function test_email_verification_screen_can_be_rendered()
- {
- $user = User::factory()->create([
- 'email_verified_at' => null,
- ]);
-
- $response = $this->actingAs($user)->get('/verify-email');
-
- $response->assertStatus(200);
- }
-
- public function test_email_can_be_verified()
- {
- $user = User::factory()->create([
- 'email_verified_at' => null,
- ]);
-
- Event::fake();
-
- $verificationUrl = URL::temporarySignedRoute(
- 'verification.verify',
- now()->addMinutes(60),
- ['id' => $user->id, 'hash' => sha1($user->email)]
- );
-
- $response = $this->actingAs($user)->get($verificationUrl);
-
- Event::assertDispatched(Verified::class);
- $this->assertTrue($user->fresh()->hasVerifiedEmail());
- $response->assertRedirect(RouteServiceProvider::HOME.'?verified=1');
- }
-
- public function test_email_is_not_verified_with_invalid_hash()
- {
- $user = User::factory()->create([
- 'email_verified_at' => null,
- ]);
-
- $verificationUrl = URL::temporarySignedRoute(
- 'verification.verify',
- now()->addMinutes(60),
- ['id' => $user->id, 'hash' => sha1('wrong-email')]
- );
-
- $this->actingAs($user)->get($verificationUrl);
-
- $this->assertFalse($user->fresh()->hasVerifiedEmail());
- }
-}
+++ /dev/null
-<?php
-
-namespace Tests\Feature\Auth;
-
-use App\Models\User;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Tests\TestCase;
-
-class PasswordConfirmationTest extends TestCase
-{
- use RefreshDatabase;
-
- public function test_confirm_password_screen_can_be_rendered()
- {
- $user = User::factory()->create();
-
- $response = $this->actingAs($user)->get('/confirm-password');
-
- $response->assertStatus(200);
- }
-
- public function test_password_can_be_confirmed()
- {
- $user = User::factory()->create();
-
- $response = $this->actingAs($user)->post('/confirm-password', [
- 'password' => 'password',
- ]);
-
- $response->assertRedirect();
- $response->assertSessionHasNoErrors();
- }
-
- public function test_password_is_not_confirmed_with_invalid_password()
- {
- $user = User::factory()->create();
-
- $response = $this->actingAs($user)->post('/confirm-password', [
- 'password' => 'wrong-password',
- ]);
-
- $response->assertSessionHasErrors();
- }
-}
+++ /dev/null
-<?php
-
-namespace Tests\Feature\Auth;
-
-use App\Models\User;
-use Illuminate\Auth\Notifications\ResetPassword;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Illuminate\Support\Facades\Notification;
-use Tests\TestCase;
-
-class PasswordResetTest extends TestCase
-{
- use RefreshDatabase;
-
- public function test_reset_password_link_screen_can_be_rendered()
- {
- $response = $this->get('/forgot-password');
-
- $response->assertStatus(200);
- }
-
- public function test_reset_password_link_can_be_requested()
- {
- Notification::fake();
-
- $user = User::factory()->create();
-
- $this->post('/forgot-password', ['email' => $user->email]);
-
- Notification::assertSentTo($user, ResetPassword::class);
- }
-
- public function test_reset_password_screen_can_be_rendered()
- {
- Notification::fake();
-
- $user = User::factory()->create();
-
- $this->post('/forgot-password', ['email' => $user->email]);
-
- Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
- $response = $this->get('/reset-password/'.$notification->token);
-
- $response->assertStatus(200);
-
- return true;
- });
- }
-
- public function test_password_can_be_reset_with_valid_token()
- {
- Notification::fake();
-
- $user = User::factory()->create();
-
- $this->post('/forgot-password', ['email' => $user->email]);
-
- Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
- $response = $this->post('/reset-password', [
- 'token' => $notification->token,
- 'email' => $user->email,
- 'password' => 'password',
- 'password_confirmation' => 'password',
- ]);
-
- $response->assertSessionHasNoErrors();
-
- return true;
- });
- }
-}
+++ /dev/null
-<?php
-
-namespace Tests\Feature\Auth;
-
-use App\Providers\RouteServiceProvider;
-use Illuminate\Foundation\Testing\RefreshDatabase;
-use Tests\TestCase;
-
-class RegistrationTest extends TestCase
-{
- use RefreshDatabase;
-
- public function test_registration_screen_can_be_rendered()
- {
- $response = $this->get('/register');
-
- $response->assertStatus(200);
- }
-
- public function test_new_users_can_register()
- {
- $response = $this->post('/register', [
- 'name' => 'Test User',
- 'email' => 'test@example.com',
- 'password' => 'password',
- 'password_confirmation' => 'password',
- ]);
-
- $this->assertAuthenticated();
- $response->assertRedirect(RouteServiceProvider::HOME);
- }
-}