Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22866,12 +22866,6 @@ parameters:
count: 2
path: tests/Feature/LoginAndRegistration.php

-
rawMessage: Using nullsafe property access on non-nullable type App\Models\User. Use -> instead.
identifier: nullsafe.neverNull
count: 1
path: tests/Feature/LoginAndRegistration.php

-
rawMessage: '''
Call to deprecated method forceRootUrl() of class Illuminate\Routing\UrlGenerator:
Expand Down
4 changes: 4 additions & 0 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
</span>
@endif
</label>
<label class="tw-label tw-cursor-pointer tw-justify-start tw-gap-2">
<input type="checkbox" name="remember" value="1" {{ old('remember') ? 'checked' : '' }} class="tw-checkbox" />
<span class="tw-label-text">Remember me</span>
</label>
<button class="tw-btn tw-btn-block tw-mt-2" type="submit">Sign In</button>
</form>
@endif
Expand Down
40 changes: 39 additions & 1 deletion tests/Feature/LoginAndRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,49 @@ public function testUserCanLoginWithCorrectCredentials(): void

// Verify that users can login with their username and password.
$response = $this->post('/login', [
'email' => $this->user?->email,
'email' => $this->user->email,
'password' => '12345',
]);
$this->assertModelExists($this->user);
$this->assertAuthenticatedAs($this->user);
}

public function testLoginFormHasRememberMe(): void
{
// Verify that the login form displays a "remember me" checkbox.
$response = $this->get('/login');
$response->assertOk();
$response->assertSeeText('Remember me');
$response->assertSee('name="remember"', false);
}

public function testUserCanLoginWithRememberMe(): void
{
$this->user = $this->makeNormalUser(password: '12345');
$this->assertModelExists($this->user);

// Verify that logging in with "remember me" checked sets the recaller cookie.
$response = $this->post('/login', [
'email' => $this->user->email,
'password' => '12345',
'remember' => '1',
]);
$this->assertAuthenticatedAs($this->user);
$response->assertCookie(Auth::guard()->getRecallerName());
}

public function testUserCanLoginWithoutRememberMe(): void
{
$this->user = $this->makeNormalUser(password: '12345');
$this->assertModelExists($this->user);

// Verify that logging in without "remember me" does not set the recaller cookie.
$response = $this->post('/login', [
'email' => $this->user->email,
'password' => '12345',
]);
$this->assertAuthenticatedAs($this->user);
$response->assertCookieMissing(Auth::guard()->getRecallerName());
}

public function testUserCannotLoginWithIncorrectCredentials(): void
Expand Down