diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e5569914d5..4c39c7b754 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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: diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 6a80ecdf96..855c26f1ef 100755 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -59,6 +59,10 @@ @endif + @endif diff --git a/tests/Feature/LoginAndRegistration.php b/tests/Feature/LoginAndRegistration.php index a8e8926a73..d4d63992e1 100644 --- a/tests/Feature/LoginAndRegistration.php +++ b/tests/Feature/LoginAndRegistration.php @@ -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