Skip to content

Commit 7a80ba6

Browse files
author
Greg Bowler
committed
Test calling login has no effect if already logged in
1 parent 47baf38 commit 7a80ba6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/phpunit/AuthenticatorTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,27 @@ public function testLoginRedirectsWithCorrectQueryString() {
156156
$sut->login($token);
157157
}
158158

159+
public function testLoginDoesNothingWhenAlreadyLoggedIn() {
160+
$sessionData = self::createMock(SessionData::class);
161+
$_SESSION = [
162+
Authenticator::SESSION_KEY => $sessionData,
163+
];
164+
165+
$redirectHandler = self::createMock(RedirectHandler::class);
166+
$redirectHandler->expects(self::never())
167+
->method("redirect");
168+
169+
$sut = new Authenticator(
170+
"test-key",
171+
"/",
172+
AuthUri::DEFAULT_BASE_URI,
173+
null,
174+
$redirectHandler
175+
);
176+
177+
$sut->login();
178+
}
179+
159180
public function testGetUuidThrowsExceptionWhenNotLoggedIn() {
160181
$_SESSION = [];
161182
$sut = new Authenticator(

0 commit comments

Comments
 (0)